Question

Iam having four select menus in my page. My problem is weird i.e. without selecting any of the dropdown menu if you click on submit, it is working fine. But when i select subgroup dropdown menu and later if i click the submit button it is not calling the method it intended to call... Heres my code..

<?xml version="1.0"?>
<f:view xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui" xmlns:ui="http://java.sun.com/jsf/facelets">
<h:head/>
<h:body>    
<h:form id="form">
            <p:panel header="Service Details" style="width:800px">

            <p:panelGrid columns="4">
                <h:outputText value="Group: " />
                <p:selectOneMenu value="#{helpDeskBean.group}">
                    <f:selectItem itemLabel="Select One" itemValue="" />
                    <f:selectItems value="#{helpDeskBean.createRequestDTO.groupsList}" var="item" itemLabel="#{item.groupdesc}" itemValue="#{item.groupid}" />
                    <p:ajax event="change" listener="#{helpDeskController.groupChange}" update="subGroupID"  partialSubmit="true"/>
                </p:selectOneMenu>


                <h:outputText value="Sub Group: " />
                <p:selectOneMenu value="#{helpDeskBean.subGroup}" id="subGroupID">
                <f:selectItem itemLabel="Select One" itemValue="" />
                    <f:selectItems value="#{helpDeskBean.groupChangeList}" var="item2" itemLabel="#{item2.subGroupDesc}" itemValue="#{item2.subGroupCode}" />
                    <p:ajax event="change" listener="#{helpDeskController.SubGroupChange}" update="serviceID" />
                </p:selectOneMenu>

                <h:outputText value="Service: " />
                <p:selectOneMenu value="#{helpDeskBean.service}" id="serviceID">
                <f:selectItem itemLabel="Select One" itemValue="" />
                    <f:selectItems value="#{helpDeskBean.groupChangeList}" var="item1" itemLabel="#{item1.serviceDesc}" itemValue="#{item1.serviceCode}" />
                </p:selectOneMenu>

            </p:panelGrid>
        </p:panel>
<p:commandButton value="Submit" actionListener="#{helpDeskController.createHDRequest}"/>
    </h:form>
</h:body>

Was it helpful?

Solution

On Second dropdown's ajax change event you are updating an id 'serviceID'. If this component is not found in your DOM tree you would have got an error in the server console stating component 'serviceID' not found.

If you got that error then that may be the possible cause. Give exact id of the component id you want to update by checking your page view source.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top