0

Using Primefaces 3.1.1.

I am trying to perform two actions on submit of 1 commandButton:

The original form elements are as follows:

<p:calendar ... value="#{bean.date1}" />
<p:calendar ... value="#{bean.date2}" />
<h:commandButton value="submit" onchange="TASK" action="#{Bean.saveOrUpdateItem()}" >
</h:commandButton>

But now, I would also like to achieve the following with the press of that same button:

<h:commandButton value="submit" action="#{bean.submit}">
    <f:ajax execute="@form" render="result" />
</h:commandButton>
<h:outputText id="result" value="#{bean.date3}" />

Any pointers on how to deal with that? I do not want to modify the first Bean.saveOrUpdateItem() and have to create the second bean.

Thank you in advance.

-V

Namenoobie
  • 541
  • 2
  • 8
  • 15
  • My guess.. its not possible. Why don't you have a single `commandButton` with only one action `submit`. On click of this, call `saveOrUpdateItem` method as well inside `submit` method? – Vikas V Jun 26 '13 at 11:10
  • Thank you, i will try this and let you know here. – Namenoobie Jun 26 '13 at 11:29
  • Hi Vikas, How could I access widgetVar from xhtml (primefaces) page in ManagedBean? I must use the widgetVars to add and then show the result. – Namenoobie Jun 26 '13 at 12:31
  • I want to achieve this apaprently: http://stackoverflow.com/questions/17320338/how-to-access-widgets-from-managedbean – Namenoobie Jun 26 '13 at 15:11

1 Answers1

2

Try to use f:actionListener

<h:commandButton value="Submit" id="submit" action="#{myBean0.action}" >
       <f:actionListener binding="#{myBean1.actionListener}"/>
            <f:actionListener binding="#{myBean2.actionListener}"/>
</h:commandButton>
Aksel Willgert
  • 11,367
  • 5
  • 53
  • 74