• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Firing two actions

 
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would be interested to know how one can fire two actions in separate beans.

Presumably something like:


will not work. So either the action in one bean has to call another, or something can be done with action listeners, or perhaps some JavaScript in the client can be used to fire the second action.

I would be most grateful to know about this.

Christopher Sharp
 
Saloon Keeper
Posts: 28316
210
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your best bet general-purpose is to subscribe action listeners.

If the relationship is simple and not subject to change, you can simply chain actions, since an action process is nothing but a method accepting void and returning a string. Just inject the dependent bean into the bean that gets fired first and invoke the second action on the dependent bean.
 
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Every action has an string that represents a logical outcome in the faces-config.xml. If you do not want to navigate to another resource, then an actionlistener.

My suggestion is to delegate the business logic inside action1 and action2 to POJO classes, which could replace both actions with a single action that delegates processing to POJO classes. Of course, other managed bean can extend this behaviour that would increase reuse of action1 and action2.

Regards.
 
Christopher Sharp
Ranch Hand
Posts: 159
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks for the reply, and I might try these.

What I have are three beans, the first is used for login, the second to handle some forms, and the third to handle file uploads. What I need to do on successful submission of the forms is to update the second and third beans. So rather than controlling the second bean directly by an action, I'm now using the login bean as the master bean, and the action is passed to the second bean, where it is processed as before, and the second and third beans are updated.

Whether this will work or not I hope to find out tomorrow.

Christopher Sharp
 
And when my army is complete, I will rule the world! But, for now, I'm going to be happy with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic