JSF AJAX Request not working with hx:panelDialog

2.9k views Asked by At

I wrote the following code,

        <h:form id="PrefForm" >
        <hx:commandExButton id="preferenceButton" type="button" style="align:right;" value="#{nls.preferenceLink }" title="#{nls.preferenceLinkTitle}" >
                    <hx:behavior event="onclick" behaviorAction="get" targetAction="prefPanelGroup"></hx:behavior>
                    <hx:behavior event="onclick" behaviorAction="show;stop" targetAction="preferenceSet"></hx:behavior>
        </hx:commandExButton>

        <hx:panelDialog id="preferenceSet"    type="modal" styleClass="panelDialog" title="#{nls.preferenceDialogTitle}" >
            <h:outputText styleClass="panelStartMessage" style="display:block;" value="#{nls.preferenceDialogWindowText}" />

            <h:panelGroup id="prefPanelGroup" rendered="#{neoReport.hasSelectItem }" style="display:block;width:300px;height:360px;overflow:auto;" >
                <hx:ajaxRefreshRequest id="refreshform" />
                <h:selectManyCheckbox value="#{neoReport.selectedItems}" layout="pageDirection">
                        <f:selectItems value="#{neoReport.selectItems}" />
                </h:selectManyCheckbox>
            </h:panelGroup> 

            <hx:panelBox id="noCommandWindow" rendered="#{!neoReport.hasSelectItem }" style="display:block;width:300px;height:50px;" layout="lineDirection"> 
                <h:outputText styleClass="outputText" id="cmdInfo"    value="#{nls.noCommands}" />
            </hx:panelBox>

            <h:panelGroup id="buttonBox1" styleClass="panelStartBox" >
                    <hx:commandExButton id="submitPref"    styleClass="commandExButton" type="submit" value="#{nls.submit}" action="#{neoReport.action}">
                        <hx:behavior event="onclick" behaviorAction="hide"    targetAction="preferenceSet" id="behaviorSubmitPref" />
                    </hx:commandExButton>
                    <hx:commandExButton id="CancelPref"    styleClass="commandExButton" type="submit" value="#{nls.cancel}" action="neoReport">
                        <hx:behavior event="onclick" behaviorAction="hide"    targetAction="preferenceSet" id="behaviorCancelPref" />
                    </hx:commandExButton>
            </h:panelGroup>
         </hx:panelDialog>
    </h:form>

Basic idea behind this code is to have a button on the page,when user click,it should get the latest data from bean( by extracting a file,which is continuously getting updated) and fill the List object in databean,so that h:selectManyCheckBox can render that. So i added a behavior with the commandExButton,so that it will get the new data and it should render the latest options in selectManyCheckBox. BUT out of these two hx:behavior,only the first one is working,its calling the getter function of

<f:selectItems value="#{neoReport.selectItems}"

but its not rendering the panelDialog further.If i remove the behavior for "get" it will show the panel dialog but not with the updated data. So i am not able to find out,what exactly wrong i am doing here.Can anyone help?

1

There are 1 answers

1
Daniel Szalay On BEST ANSWER

First of all I don't know what type of tag library is this. You should point it out in the tags and/or in the question.

You should have only one <hx:behavior> tag, which does all the job for you. If doing so, you should have a method that calls all three methods. Is it possible with these tags to rerender multiple components with AJAX - like targetAction="prefPanelGroup, preferenceSet"?

As far as I know, rerendering preferenceSet will cause prefPanelGroup to rerender too, so it's pointless to rerender separately.

Also, rerendering prefPanelGroup will work only by telling the <hx:behavior> tag a more precise id, like "PrefForm:prefPanelGroup".

Hope this helps, Daniel