当前位置: 动力学知识库 > 问答 > 编程问答 >

jsf - Having trouble presenting an error free screen with Multiple SelectOneMenu drop-downs that are dependent on the previous choice

问题描述:

Newby here. Would appreciate some direction or assistance. Thanks in advance.

If the user clicks the Submit button before all choices have been made the screen error's with a NullPointerException.

HTML

 <p:panel header="Wip-Emails Employee Assignment List">

<p:panelGrid id="pg1" columns="4" styleClass="veaGrid: semialert"

cellpadding="5">

<h:outputText value="WIP Departments:" />

<p:selectOneMenu style="width:300px" value="#{wipe.wipDepartments}"

var="dpt" id="wipDpt" converter="omnifaces.SelectItemsConverter"

required="true" requiredMessage="Please select a Department" >

<f:selectItem itemLabel="1st - Select a Department" noSelectionOption="true" itemValue="#{null}"/>

<f:selectItems value="#{wipe.wipdepartments}" var="dpts"

itemLabel="#{dpts.chf_dept_cd} - #{dpts.chf_dept_des}"

itemValue="#{dpts}" />

<p:column>

<h:outputText value="#{dpt.chf_dept_cd}" />

</p:column>

<p:column>

<h:outputText value="#{dpt.chf_dept_des}" />

</p:column>

<f:ajax listener="#{wipe.loadEmployeeList}" render="wipUsr" />

</p:selectOneMenu>

<h:outputText value="Department Employees:" />

<p:selectOneMenu style="width:300px" value="#{wipe.wipUsers}"

var="usr" id="wipUsr" converter="omnifaces.SelectItemsConverter"

required="true" requiredMessage="Please select an Employee">

<f:selectItem itemLabel="2nd - Select an Employee" noSelectionOption="true" itemValue="#{null}"/>

<f:selectItems value="#{wipe.wipusers}" var="usr"

itemLabel="#{usr.sec_usr_id} - #{usr.cicl_lng_nm}"

itemValue="#{usr}" />

<p:column>

<h:outputText value="#{usr.sec_usr_id}" />

</p:column>

<p:column>

<h:outputText value="#{usr.cicl_lng_nm}" />

</p:column>

<f:ajax listener="#{wipe.loadSystemGroupCodes}" render="wipGrp" />

</p:selectOneMenu>

<h:outputText value="System Groups:" />

<p:selectOneMenu style="width:300px" value="#{wipe.wipGroup}"

var="grp" id="wipGrp" converter="omnifaces.SelectItemsConverter"

required="true" requiredMessage="Please select a System Code">

<f:selectItem itemLabel="3rd - Select a System Code" noSelectionOption="true" itemValue="#{null}"/>

<f:selectItems value="#{wipe.wipgroups}" var="grp"

itemLabel="#{grp.ctc_tag_cd} - #{grp.tag_grp_cd}"

itemValue="#{grp}" />

<p:column>

<h:outputText value="#{grp.ctc_tag_cd}" />

</p:column>

<p:column>

<h:outputText value="#{grp.tag_grp_cd}" />

</p:column>

<f:ajax listener="#{wipe.loadwipActivityIDs}" render="wipacy" />

</p:selectOneMenu>

<h:outputText value="Activity Reference IDs" />

<p:selectOneMenu style="width:300px" value="#{wipe.wipActivityId}"

var="acy" id="wipacy" converter="omnifaces.SelectItemsConverter"

required="true" requiredMessage="Please select a Reference ID">

<f:selectItem itemLabel="4th - Select a Reference ID" noSelectionOption="true" itemValue="#{null}"/>

<f:selectItems value="#{wipe.wipactivityids}" var="acy"

itemLabel="#{acy.acy_id} - #{acy.acy_txt}" itemValue="#{acy}" />

<p:column>

<h:outputText value="#{acy.acy_id}" />

</p:column>

<p:column>

<h:outputText value="#{acy.acy_txt}" />

</p:column>

</p:selectOneMenu>

</p:panelGrid>

<p:commandButton value="ADD"

action="#{wipe.addEmailAssignment}"

update=":form1:messages"

process="pg1"

icon="ui-icon-check" />

</p:panel>

Bean

private ArrayList<WipDepartments> wipdepartments;

private WipDepartments wipDepartments;

private ArrayList<WipUsers> wipusers;

private WipUsers wipUsers;

private ArrayList<WipGroups> wipgroups;

private WipGroups wipGroup;

private ArrayList<WipActivityID> wipactivityids;

private WipActivityID wipActivityId;

private String wipGroupID;

private String userID;

private String activityID;

private String clientID;

private String deptId;

--

public void loadEmployeeList(AjaxBehaviorEvent event) {

WipDepartments wipDept = wipDepartments;

setWipusers(BillingUtilsDAO.getWipUsers(wipDept.getChf_dept_id()));

}

public void loadSystemGroupCodes(AjaxBehaviorEvent event){

setWipgroups(BillingUtilsDAO.getWipGroups());

}

public void loadwipActivityIDs(AjaxBehaviorEvent event){

WipGroups wipgrp = wipGroup;

setWipactivityids(BillingUtilsDAO.getWipActivityID(wipgrp.getTag_grp_cd(), wipgrp.getCtc_tag_cd()));

}

分享给朋友:
您可能感兴趣的文章:
随机阅读: