0

just a quick question but one that is annoying me

basically i have some validation that a user must select one radio button before continuing, and when i press the submit button i get the ajax message telling me that i need to select a radio button, but also i get the pop up from the command button informing the user of the mark, is there anyway to disable the pop up unless validation has been successful

this is the code for the radio buttons

<p:column>  
                        <br></br>
                        <p:selectOneRadio id="radioButtons" value="#{formBean.number}" layout="grid" columns="1"   required = "True"
                                          requiredMessage="#{bundle.messageSelectMarkRange}" > 
                            <f:selectItem itemLabel="0 - 19" itemValue="1" /> 
                            <f:selectItem itemLabel="20 - 39" itemValue="2" />  
                            <f:selectItem itemLabel="40 - 49 " itemValue="4" />
                            <f:selectItem itemLabel="50 - 59" itemValue="5" />
                            <f:selectItem itemLabel="60 - 69" itemValue="6" />  
                            <f:selectItem itemLabel="70 - 79" itemValue="7" />  
                            <f:selectItem itemLabel="80 - 100" itemValue="8" />  
                            <p:ajax process="@this" update="mySpinnerPanel comments" />
                        </p:selectOneRadio>  
                    </p:column>

and this is the command button

        <p>
            <p:commandButton value="#{bundle.buttonNextSection}"  icon ="ui-icon-disk" update="displayMark :growl" oncomplete="PF('dlg').show()" /> 
        </p>
        <p:dialog header="Confirm Mark" widgetVar="dlg" showEffect="fold" hideEffect="fold">  
            <h:panelGrid id="displayMark" columns="2" cellpadding="5">  
                <h:outputText value="Mark to be submitted: " />  
                <h:outputText value="#{markingBean.markSectionOne.markSectionOne}" />  
                <h:outputText value="For student number : " />
                <h:outputText  value="#{markingBean.studentNumber}" />
                <p:commandButton action="#{markingBean.markSectionOne}" value="#{bundle.buttonSave}" update=":growl" icon="ui-icon-disk"/>
              <!--  <p:button outcome="/lecturer/marking/marking-section-two" value="#{bundle.buttonNextSection}"  icon ="ui-icon-arrowthick-1-e" />
                -->
            </h:panelGrid>  
        </p:dialog>  

i just want to stop the dialog box poping up if the validation is not successful

Thanks

user2061913
  • 910
  • 2
  • 14
  • 34

1 Answers1

2
<p>
    <p:commandButton value="#{bundle.buttonNextSection}" icon="ui-icon-disk"
        update="displayMark :growl checkValidation" />
</p>

<p:panelGroup id="checkValidation">
    <h:outputScript rendered="#{facesContext.validationFailed}">
        PF('dlg').show();
    </h:outputScript>
</p:panelGroup>

<p:dialog header="Confirm Mark" widgetVar="dlg" showEffect="fold" hideEffect="fold">
    <h:panelGrid id="displayMark" columns="2" cellpadding="5">
        <h:outputText value="Mark to be submitted: " />
        <h:outputText value="#{markingBean.markSectionOne.markSectionOne}" />
        <h:outputText value="For student number : " />
        <h:outputText value="#{markingBean.studentNumber}" />
        <p:commandButton action="#{markingBean.markSectionOne}"
            value="#{bundle.buttonSave}" update=":growl" icon="ui-icon-disk" />
        <!-- <p:button outcome="/lecturer/marking/marking-section-two" value="#{bundle.buttonNextSection}" 
            icon ="ui-icon-arrowthick-1-e" /> -->
    </h:panelGrid>
</p:dialog>

reference: https://stackoverflow.com/a/15384529/1602621

Community
  • 1
  • 1
zsoltii
  • 96
  • 1
  • 4