簡體   English   中英

jsf a4j:commandButton reRender不起作用

[英]jsf a4j:commandButton reRender doesn't work

如果將第一個按鈕更改為h:commandButton,則我的jsf頁面可以正常工作。 但是,這會刷新提交時的整個頁面,因此我的要求是將兩者都保留為ajax支持的按鈕。 我的支持bean具有所有必需的方法。 單擊第二個按鈕時,以下代碼不會打印出選擇。 日志顯示“ null”作為選擇。 我究竟做錯了什么?

<h:form>
<a4j:commandButton action="#{Bean.getAllReps}" value="Get REPS" reRender="showReps" />
</h:form>
<h:panelGrid columns="1" id="showReps">
    <h:panelGrid rendered="#{Bean.actionComplete eq 'fail'}" width="100%" columns="2">
        <h:outputText value="Could not get Details" style="color: red; font-size:3mm;" />
    </h:panelGrid>
            <h:panelGrid rendered="#{Bean.actionComplete eq 'success'}">
                <h:panelGrid>
                    <h:outputText>
                        <rich:panel>
                            <h:form>
                                <h:panelGrid>
                                    <rich:pickList value="#{Bean.slctdRep}" style="text-align: left;">
                                        <f:selectItems value="#{Bean.allReps}" />
                                    </rich:pickList>
                                </h:panelGrid>

                                <a4j:commandButton value="Show Selection" reRender="content" type="submit"></a4j:commandButton> //This button doesn't perform partial refresh on element with id "content"

                            </h:form>
                        </rich:panel>
                        <rich:panel>
                            <h:panelGroup id="content" layout="block">
                                <h:outputText value="Selected Reps : "></h:outputText>
                                <h:outputText value="#{Bean.selectedRepsInString}"></h:outputText>
                            </h:panelGroup>
                        </rich:panel>

                    </h:outputText>
                </h:panelGrid>
            </h:panelGrid>
</h:panelGrid>

我發現了問題,我有兩個表單標簽,每個按鈕一個,這就是問題所在。 我將整個代碼包裝成一種形式,現在可以按需運行了。

從這里獲得解決方案: commandButton / commandLink / ajax action / listener方法未調用或輸入值未設置/更新

更新的代碼:

<a4j:form>
    <a4j:commandButton action="#{Bean.getAllReps}" value="Get REPS" reRender="showReps" type="submit" />
    <h:panelGrid columns="1" id="showReps">
        <rich:panel>
            <h:panelGrid>
                <rich:pickList sourceListWidth="200" targetListWidth="200" value="#{Bean.slctdRep}">
                    <f:selectItems value="#{Bean.allReps}" />
                </rich:pickList>
            </h:panelGrid>

            <a4j:commandButton value="Show Selection" reRender="content" type="submit" action="#{Bean.getSelectedReps}" />
        </rich:panel>

        <rich:panel>
            <h:panelGroup layout="block" id="content">
                <h:outputText value="#{Bean.selectedReps}"></h:outputText>
            </h:panelGroup>
        </rich:panel>

    </h:panelGrid>
</a4j:form>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM