Forum Stats

  • 3,735,151 Users
  • 2,247,117 Discussions
  • 7,857,728 Comments

Discussions

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

Daniel López
Daniel López Member Posts: 34
edited Jun 11, 2015 11:57AM in JDeveloper and ADF

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.

Tagged:

Best Answer

  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,094 Red Diamond
    edited Jun 11, 2015 12:31AM Accepted 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


Answers

  • aJohny
    aJohny Member Posts: 4,856 Silver Crown
    edited Jun 10, 2015 9:24PM

    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
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,094 Red Diamond
    edited Jun 11, 2015 12:31AM Accepted 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


  • Daniel López
    Daniel López Member Posts: 34
    edited Jun 11, 2015 10:17AM

    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
    aJohny Member Posts: 4,856 Silver Crown
    edited Jun 11, 2015 10:24AM

    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

    Daniel López
  • aJohny
    aJohny Member Posts: 4,856 Silver Crown
    edited Jun 11, 2015 10:25AM
  • Daniel López
    Daniel López Member Posts: 34
    edited Jun 11, 2015 10:28AM

    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
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,094 Red Diamond
    edited Jun 11, 2015 10:41AM

    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
    Daniel López Member Posts: 34
    edited Jun 11, 2015 10:54AM

    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
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 37,094 Red Diamond
    edited Jun 11, 2015 11:00AM

    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
  • Daniel López
    Daniel López Member Posts: 34
    edited Jun 11, 2015 11:15AM
  • Daniel López
    Daniel López Member Posts: 34
    edited Jun 11, 2015 11:57AM

    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.

This discussion has been closed.