Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

ADF Refresh page jsf with page fragments jsff after set session variable

Daniel LópezJun 10 2015 — edited Jun 11 2015

Hello.

I have a template which includes a button that let you select a profile, you push the button and appear the available profiles, choose one and push accept. After that I set a variable session successfully.

I have a "First" jsf page with two jsff page fragments from a View Link. The view link is composed by a headerView and detailView. The headerView had a bind variable. What I need is that parameter (bindVariableParameter) can be set by the session variable of the template.

This is what I get:

I am in a home page (separate Application Module), I push the template button before I load de "First" jsf page and after that I go to the "First" jsf page the information is loaded successfully. What I do in the Application Module is something like that:

    protected void prepareSession(Session session) {

    Map sessionScope = ADFContext.getCurrent().getSessionScope();

    String company = (String)sessionScope.get("compId");

    System.out.println("Default Comapny in BC is: " + company);

    super.prepareSession(session);

    this.getSession().getUserData().put("Company", company);

    System.out.println("After setting value in userData map of BC");

    }

And in the bind variable expression of the headerView I use:

    adf.userSession.userData.Company

It works great!!!! But!!!!

When I press the button again and I choose another profile, the info is not updated. Neither in the headerView neither in the detailView.

Also, when I go to the "First" jsf page (without previously push the template button), I got no info, which is right, because I don't have any session variable. After that I push the template button and select the profile, but the page is not refreshed.

I tried several ways to to this but I'm lost.

Could you help me?

Regards.

This post has been answered by Timo Hahn on Jun 11 2015
Jump to Answer

Comments

aJohny Jun 10 2015

I think the prepareSession will get called only when the AM is first created or  when  associated with a user session.

Did you check your debug statements are getting printed when you click the button second time ?

Cheers

AJ

Timo Hahn Jun 11 2015 — edited on Jun 11 2015
Answer

I'm not sure I understand your use case. From what I get you set a parameter after you push a button in the home page to pass this parameter to the first.jsf.

Why don't you implement a method in the application module and call it with the parameter directly. The prepare session will not be called every time you navigate but only to init the am.

Do you need the parameter in the model layer or only in the view?

Timo

Marked as Answer by Daniel López · Sep 27 2020
Daniel López Jun 11 2015

That's right. I already tried that. The prepare session only loads once.

I already try to implement in the manage bean of the button something like that:

        ApplicationModule am = Configuration.createRootApplicationModule(amDef, config);

        ModuleImpl amImpl = (ModuleImpl) am;

        ViewObject viewObject = amImpl.findViewObject("QueryView1");

        viewObject.setNamedWhereClauseParam("bind_user_name", var);

        viewObject.executeQuery();

But the page don't refresh any new data.

I'm not really sure if the executeQuery is working.

Do you have any ideas?

Thanks in advance.

aJohny Jun 11 2015

Don't create AM in your code.

Instead, create a method in the AM and get the handle of the VO and execute the query in that.

Expose that AM method as a client interface in the AM. Add that method as a method binding in your Page.

Call that method from the Bean method which gets called on the button click.

Ad the button as the partialTrigger for the region which shows the VO content.

This should refresh the data in the page.

Cheers

AJ

aJohny Jun 11 2015
Daniel López Jun 11 2015

I will use that session variable in many other jsf pages. Is the parameter for filter what the user have access.

For example:

USER1 have Profile1 and Profile2

USER2 have Profile2

Profile1 have access to key1 and key2

Profile2 have access to key3

Then, USER1 can access to the info on View1 [View1...2...3...4] but only with the key1 and key2. USER2 only can see the information related with key3.

I mean:

     SELECT *

     FROM     table1

     WHERE  key = l_key

I hope you understand me.

Regards.

Timo Hahn Jun 11 2015

As I mentioned before and as @"aJohny" did too, you should implement a method in the AM and call this method from the bean. The technique was mentioned too.

Don't use CreateRootApplicationModule in a bean (or better don't use it at all) as this won't be accessible from the other page!

Timo

Daniel López Jun 11 2015

I already tried that.

In my AMModuleImpl I wrote:

    public void refreshView() {

        ViewImpl view = getView1();

        view.executeQuery();

    }


I add it to the task-flow-fragment like a methodAction, and call it before load the jsff page.

And the method is called successfully. But the page don'd refresh any data


Is that what you mean?

Timo Hahn Jun 11 2015

The method you should call should have a parameter where you pass the parameter (compId or company) you then store in the user data of the application module to use it in other queries. It's like you prepare the session yourself every time you do the navigation.

The way you use the methos just ecevures the currently active query again and you get the same data.

Timo

Daniel López Jun 11 2015

I understand.

For implement, do you men something like this Andrejus Baranovskis Blog: Solution for Sharing Global User Data in ADF BC ?

Daniel López Jun 11 2015

I tried another recommendation:

In the application module:

"jbo.doconnectionpooling=true

jbo.txn.disconnect_level = 1

This will ensure prepareSession() method is being called before each operation. This happens to be a best practice in ADF productions systems, increasing scalability."

It works.

1 - 11
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Jul 9 2015
Added on Jun 10 2015
11 comments
2,606 views