I am using JSF and I have the following problem:
I have 2 command buttons:
<h:commandButton id="btn1" value="Button 1" action="#{bean.action1()}"
onclick="#{rich:component('confirmation')}.show();" />
<h:commandButton id="btn2" value="Button 2" action="#{bean.action2()}"
onclick="#{rich:component('confirmation')}.show();" />
So, when they are clicked, a popup should show (with id="confirmation").
Here is the popup:
<rich:popupPanel id="confirmation" header="Note" modal="true"
width="525" height="180" resizable="false" headerClass="rf-p-hdr"
autosized="false">
<a4j:queue ignoreDupResponses="true" requestDelay="500" />
<f:facet name="controls">
<h:panelGroup>
<a4j:commandButton
image="#{resource['default:img/close_button.png']}"
styleClass="close_button" action="#{bean.cancel()}"
render="@all"
oncomplete="#{rich:component('confirmation')}.hide(); return false;"
status="ajaxProgress" />
</h:panelGroup>
</f:facet>
<s:div styleClass="help_embedded"
style="margin-bottom: 20px; margin-top: 20px;">
<h:outputText value="Here I want to display a message that tells the user which button was pressed." />
</s:div>
<s:div style="margin-left: 82px;">
<s:decorate template="/layout/field.xhtml">
<a4j:commandButton value="#{messages['allPages.button.save']}"
action="#{bean.save()}" execute="@this"
oncomplete="#{rich:component('confirmation')}.hide(); return false;"
render="@all"
status="ajaxProgress" />
<a4j:commandButton value="#{messages['allPages.button.cancel']}"
styleClass="cancel" action="#{bean.cancel()}"
execute="@this"
oncomplete="#{rich:component('confirmation')}.hide(); return false;"
render="@all"
status="ajaxProgress" />
</s:decorate>
</s:div>
</rich:popupPanel>
My problem is: if you look at the h:outputText inside the popup - I want it to display a message to the user based on which command button was pressed (btn1 or btn2). For example, if the user pressed btn1, the popup message will be - "You just pressed button 1. Are you sure you want to perform this action?". And if the user pressed button 2, the message would read: "You just pressed button 2. Are you sure you want to perform this action?".
I have tried updating a backing bean value each time a button is pressed and then rerendering the popup, but is seems like the popup tag is generated only once when the page loads and rerendering it does nothing.
I would also like a solution where all dynamic changes to the UI occur on the front - end only, without bothering the server to regenerate the page - so pressing button 1 will modify a javascript front end variable and the h:outputText in the popup will read this value to display the message.
Do you have an idea how this can be achieved?