0

I have a form and in the form I have a p:dialog - searchGameDetails.xhtml

Mainform.xhtml

            <h:form id="newApplication" enctype="multipart/form-data">

       </h:form>

    <p:dialog header="Game Search" widgetVar="gameSearch"  modal="true" appendTo="@(body)">
        <h:form id="gameSearchScreenForm">
            <p:panel id="gamesearchmodal" widgetVar="searchmodalpanel" styleClass="panelNoBorder">
                <ui:include src="/jsf/searchGameDetails.xhtml">     </ui:include>

            </p:panel>
    </h:form>
    </p:dialog>

searchGameDetails.xhtml

<p:panel id="searchscreen" widgetVar="searchmodalpanel">
    <h:panelGroup id="srchOpt">
        <h:panelGrid styleClass="panelGridBorderRemove" columns="5" cellpadding="7" style="font-weight:bold;width:100%;">

            <p:row>
                <p:column><p:outputLabel value="District"/></p:column>                      
                <p:column>
                    <p:selectOneMenu label=" Select District " id="district" value="#{searchGameBean.selectedDistrict}">
                            <f:selectItem itemLabel="Select District" itemValue="" />                       
                            <f:selectItems value="#{gameMB.districtList}" />
                    </p:selectOneMenu>
                </p:column>
            </p:row>


                <p:column>
                    <p:outputLabel value="Game Name" style="font-weight:bold" />
                    <p:message for="gameName" display="text" />
                    <p:inputText id="gameName" maxlength="20" size="25" value="#{searchGameBean.gameName}" />
                </p:column>

            <p:row>                     
                <p:column>
                    <p:commandButton id="searchButton" value="Search" widgetVar="searchB" actionListener="#{gameSearchMB.search}" update="gameSearchScreenForm">
                    <f:param name="param1" value="#{searchfor}" />
                    </p:commandButton>
                </p:column>

                <p:column>
                    <p:commandButton type="reset" value="Reset"  update="searchscreen" process="@this" actionListener="#{gameSearchMB.reset}"/>
                </p:column>

            </p:row>

        </h:panelGrid>

        <h:panelGrid columns="2" cellpadding="5">
            <p:dataTable id="searchTable"
                value="#{gameSearchMB.searchPageResultsList}"
                emptyMessage="No results found for search.">


                <p:column headerText="District" style="width:9%" sortBy="#{searchResultsRow.districtNumber}" filterBy="#{searchResultsRow.districtNumber}">
                    <h:outputText value="#{searchResultsRow.districtNumber}" />
                </p:column> 
                <p:column headerText="Game Name" style="width:9%" sortBy="#{searchResultsRow.gameName}" filterBy="#{searchResultsRow.gameName}">
                    <h:outputText value="#{searchResultsRow.gameName}" />
                </p:column>
            </p:dataTable>
        </h:panelGrid>

    </h:panelGroup>
</p:panel>

The search functionality works fine, Upon search by a game name the datatable would be displayed with the searchPageResultsList.

Actual Issue/Output

I'm having issue with the reset button
Where upon clicking the reset button the

It is does not clear the values from the fields

 <p:inputText  , <p:selectOneMenu  and  datatable <p:dataTable

This is what I have tried

                <p:column>
                    <p:commandButton type="reset" value="Reset"  update="searchscreen" process="@this" actionListener="#{gameSearchMB.reset}"/>
                </p:column>

public void reset() {
    logger.debug("Attempting to clear values in Datatable");
    RequestContext.getCurrentInstance().reset("panel:searchscreen");
    this.searchPageResultsList = null;
}

Expected Output

Where upon clicking the reset button It must clear the input values and also the Output datatable

    <p:inputText  , <p:selectOneMenu  and  datatable <p:dataTable
lena
  • 5
  • 4

1 Answers1

0

Have you tried with primefaces component resetInput ?

WoAiNii
  • 1,003
  • 1
  • 11
  • 19