Forum Stats

  • 3,873,344 Users
  • 2,266,537 Discussions
  • 7,911,514 Comments

Discussions

Can valueChangeListener be used to execute task flow logic?

Steven Zorb
Steven Zorb Member Posts: 113
edited Sep 19, 2012 11:24AM in JDeveloper and ADF
JDev 11.1.2.1

I have a selectOneChoice. I have set up a valueChangeListener for the soc which works fine. I have a button that takes an action within my task flow. Right now the user must make a selection in the soc and then click the button to take an action (cause navigation within) the task flow. Can I set up the soc valueChangeListener to take the same action that is now being invoked via the button? That way when the user makes a selection in the soc the task flow logic is automatically invoked.

Thanks, Steve

Best Answer

  • prateekazam
    prateekazam Member Posts: 386
    edited Sep 19, 2012 12:23AM Answer ✓
    public void valueBacking(ValueChangeEvent valueChangeEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    context.getApplication().getNavigationHandler().handleNavigation(context,"", "Go");
    // Add event code here...
    }
    instead of Go use your Action Value.


    Thanks
    Prateek

Answers

  • prateekazam
    prateekazam Member Posts: 386
    edited Sep 19, 2012 12:23AM Answer ✓
    public void valueBacking(ValueChangeEvent valueChangeEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    context.getApplication().getNavigationHandler().handleNavigation(context,"", "Go");
    // Add event code here...
    }
    instead of Go use your Action Value.


    Thanks
    Prateek
  • Timo Hahn
    Timo Hahn Senior Principal Technical Consultant - Oracle ACE Director Member, Moderator Posts: 38,904 Red Diamond
    I guess you can, but it would confuse me as a user. Doing it this way would leave no margin of error. If I selected the wrong item, I have no chance to correct this add you already navigated away.

    If you really wasn't to do this, you can queue an event for the button from you value change listener.


    Timo
    Timo Hahn
  • Frank Nimphius-Oracle
    Frank Nimphius-Oracle Member Posts: 29,689 Bronze Badge
    Hi,

    DON'T use THIS!
    public void valueBacking(ValueChangeEvent valueChangeEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    context.getApplication().getNavigationHandler().handleNavigation(context,"", "Go");
    // Add event code here...
    }
    As you have a command button on your page to perform the action, you can queue the action in the ValueChangeListener

    RichCommandButton button = ... get backing bean reference to the command button ...
    ActionEvent ae = new ActioneEvent(button);
    ae.queue();


    This will virtually press the button and navigation will be performed

    Frank
    Frank Nimphius-Oracle
  • prateekazam
    prateekazam Member Posts: 386
    Hi Frank ,

    Can you please let me know why the approached which i have given not correct ?

    Just i want to know .

    Thank
    Prateek
  • Steven Zorb
    Steven Zorb Member Posts: 113
    I tried both of these solutions. Each seems to work very well. If both are equal then I would prefer the one that does not require a button to exist.

    Frank, Is there a reason that queueing an event to the button is better?

    Timo, Thanks for the user interface advice. The user will be selecting a week. The data for the week will be displayed. In this case I think it will be more straight forward for the user.

    Thanks to all, Steve
This discussion has been closed.