user942059
user942059

Reputation: 45

Richfaces poupPanel is shown before action execution

I have JSF 2.0 form that looks like this

<h:form id="formId">
.
.
.
       <a4j:commandButton action="#{bean.myAction}" value="foo"  oncomplete="#{rich:component('popup')}.show();" />
</form>
 <rich:popupPanel id="popup" modal="false" autosized="true"
                              resizeable="false">

                <h:form id="form2">
                    <h:panelGrid columns="1" >               
                            <h:outputText id="idText" value="#{bean.message}" />
                        <h:commandButton action="#" onclick="#{rich:component('popup')}.hide(); return false;" value="ok"/>
                    </h:panelGrid>
                    </h:form>

            </rich:popupPanel>

and bean method

 public String action(){
    message = "Some message";
    return "";
}

Clicking the button both "action" and popup show are executed, but looks like calling the popup was executed first. I get message from bean constructor not the changed one. Do you have any idea how to delay popup show action (it is already under the oncomplete attribute)? Is there any usual pattern that can fit here (action dynamically changes content of popup panel, popup should be like outcome message). Or maybe there is a way to invoke popup show from java code(for example from bean.action)? Thanks

Upvotes: 2

Views: 1816

Answers (1)

BalusC
BalusC

Reputation: 1108632

You need to re-render the <rich:popupPanel>s content first, otherwise it is still showing the content from the first time it was rendered. You're namely redisplaying already-rendered-but-hidden-by-CSS content by JavaScript.

<a4j:commandButton render=":popup:form2" ... />

Upvotes: 1

Related Questions