7 Replies Latest reply on Apr 18, 2013 3:32 PM by dslack

    Custom phaseListener - issue with jsff

      Hello all,

      I have been playing with custom phase listener classes to preset some values on a few pages.


      Following this documentation I've found that I can get my phase listener to work just fine for a standard jsf page. I create my listener java class and set the ControllerClass attribute in the pageDef.xml using an el expression that resolves to that class by sticking it in the pageFlowScope of my task flow. However, for my jsff pages I can't get this to work. I've tried a few things:

      1.) Following my previous technique that worked for jsf, ControllerClass set to the el expresion #{pageFlowScope.phaseImpl} results in a class not found exception.

      2.) Try setting ControllerClass to actual path. "com.package.beans.PhaseImpl cannot be cast to oracle.adf.model.RegionController".

      3.) Try setting ControllerClass to oracle.adf.model.RegionController as the documentation suggests. "ADF: Adding the following JSF error message: oracle.adf.model.RegionController
      java.lang.InstantiationException: oracle.adf.model.RegionController"

      I'm not sure if I'm misinterpreting the document, but does anyone have advice for what I could be doing wrong specifically for a page fragment calling a custom phaseListener?

      Thanks in advance!
        • 1. Re: Custom phaseListener - issue with jsff
          for fragments you should extend oracle.adf.model.RegionController
          • 2. Re: Custom phaseListener - issue with jsff
            This appears to what's wrong, thanks! But I do have a few more questions. According the the document:

            "Standard JSF page - specify oracle.adf.controller.v2.lifecycle.PageController

            If you need to receive afterPhase/beforePhase events, specify oracle.adf.controller.v2.lifecycle.PagePhaseListener

            Page fragment - specify oracle.adf.model.RegionController"

            My issue was that I thought I could extend PagePhaseListener to receive the afterPhase and beforePhase events for jsff too since my task is to dynamically preselect some dropdowns and fill in some input text depending on what occurred before this page. Can I not do this with a page fragment? Does anyone have an alternative solution for this task?

            I'd appreciate anymore help.

            Edited by: dslack on Apr 16, 2013 2:30 PM
            • 3. Re: Custom phaseListener - issue with jsff
              may be try like, yourclass implements RegionController, PagePhaseListener {                                                                                                                                                                                       
              1 person found this helpful
              • 4. Re: Custom phaseListener - issue with jsff
                Frank Nimphius-Oracle

                honestly I think you want to share your use case with us instead of poking on a failed implementation. A region controller notifies you about the prepareModel and the prepareRender phase of a region and does not have access to the binding layer of the JSF page context. So even if you get the region controller working its not doing for what you want it to do. If you are on JDeveloper 11g R2 you could use JSF 2 system events to listen for the pre-render response phase to manipulate a component state. Here a JDeveloper version and a use case would have been useful.

                1 person found this helpful
                • 5. Re: Custom phaseListener - issue with jsff
                  Hello Frank,

                  Here's what were running:

                  ADF Business Components
                  Java(TM) Platform     1.6.0_24
                  Oracle IDE
                  Versioning Support

                  There's not a formal use case for this one, just a side "nice-to-have". Not sure if it'll stay a nice to have though ;) ... I'll describe briefly what I have and what I want to do.

                  One bit of working functionality in our application includes the creation of a "solution". This includes a flow where the user populates the values with a variety of components and we ultimately create all of the rows in the db and commit as we intend. All kinds of logic takes place but its been tested and is considered completed, its actually in production.

                  Now there's a second use case which I'm modifying. In this flow we can open a previously created solution and look at all of its assigned "tools". We can also create a new "tool". It seems like the end-users are resistant to selecting certain values on this creation flow and its more of a mess in the db then it should be. So depending on the solution we are looking at I have values that I have configured to be preset on the tool creation screen so that the laziest of end users will have populated the tool with something in the ballpark of what they expect, and from there if something needs to change the end-user does it.

                  Right now I have a "Preset" button that does exactly this. It taps a bean whose logic sets these default values dependent on the solution data. Works great. I am looking for a way to execute this same bean logic so that the screen is "Preset" when it first appears though. And this is where we are at, attempting to use phase listeners.
                  • 6. Re: Custom phaseListener - issue with jsff
                    Frank Nimphius-Oracle

                    in JDeveloper 11.1.2.x (R2) and JSF 2 one could have used the new JSF system events (which is why I asked for the JDev version). In Jdeveloper 11g R1 you don't have this. The "trick" here is to add a hidden output text component" and reference a managed bean setter/getter pair (bean property) from its value* property. Note that hidden means rendered="true" and visible="false". The getter method that the value property references only returns an empty string, but executes all the pre-settings you want to do. You could for example keep your button (in case users want to explicitly recover this state after some changes they've done) and use the managed bean code to invoke it upon page load by having the getter method calling

                    ActionEvent ae = new ActionEvent(the_button);

                    Or, if you don't need the button, just execute the same code in the getter_method.

                    Its a work around that later you change to the use of System events when upgrading e.g. to 12c

                    1 person found this helpful
                    • 7. Re: Custom phaseListener - issue with jsff
                      Thanks Frank, this works!

                      I actually didn't end up using a getter/setter pair for the value property, that wasn't working for some reason. At whatever point this was being executed the iterators in my bindings layer were empty it seems. The code is ran but my preset values weren't found.

                      Rather I had to make a getter/setter for the render property itself. Basically I'm executing the "preset" logic and then returning false in my getter, which works exactly the way I hoped. Iterators were there so I could find and set the default values to what I wanted. Shrugs Unfortunately I don't have much time to dive deeper and figure out what exactly is going on with the bindings layer of my page context when render and value are calling their respective getters.

                      Appreciate your replies, made note of this trick for future reference.

                      Regards - Dylan Slack

                      Edited by: dslack on Apr 18, 2013 8:32 AM

                      Edited by: dslack on Apr 18, 2013 8:32 AM