0

So, I have a form which basically makes a team

<h:form id="AddTeam">
<p:growl id="growl" showDetail="true"></p:growl>
<table>
    <tr><td><p:outputLabel for="TeamName" value="Enter New Team Name"></p:outputLabel></td><td><p:inputText style="width:100%" id="TeamName" required="true" value="#{teamMaintainanceController.teamName}"></p:inputText></td></tr>
    <tr><td><p:outputLabel for="TeamDesc" value="Enter New Team's Description"></p:outputLabel></td><td><p:inputText style="width:100%" id="TeamDesc" required="true" value="#{teamMaintainanceController.teamDesc}"></p:inputText></td></tr>
    <tr><td><p:outputLabel for="TeamProj" value="Assign a preexisting project"></p:outputLabel></td><td><p:selectOneMenu style="width:100%" id="TeamProj" value="#{teamMaintainanceController.teamProject}">
                <f:selectItem style="width:100%" itemLabel="Select One" itemValue="" />
                <f:selectItems style="width:100%" value="#{projectMaintainanceController.allProjects}"/>
        </p:selectOneMenu></td></tr>
    <tr><td><p:outputLabel for="teamMemb" value="Select Team Members"></p:outputLabel></td><td><!-- <p:selectCheckboxMenu id="teamMemb" value="#{teamMaintainanceController.teamMemb}">
        <f:selectItems value="#{employeeMaintainanceController.possibleManagerList}"></f:selectItems>
    </p:selectCheckboxMenu> --><p:button value="Select Team Members" id="teamMemb" onclick="teammembers.show();return false;"></p:button></td></tr>

    <tr><td><p:commandButton id="applyBtn" value="Add" ajax="true" actionListener="#{teamMaintainanceController.addTeam}" update=":AddTeam:growl"/></td></tr>
</table>

</h:form></center>

<p:dialog header="Select Team Members" widgetVar="teammembers" modal="true">
<h:form>
    <p:dataTable var="user" rowKey="#{user.id}" value="#{employeeMaintainanceController.userList_ALL}" selection="#{teamMaintainanceController.selectedUsers}" selectionMode="multiple">
        <p:column headerText="id">
            <h:outputText value="#{user.id}"></h:outputText>
        </p:column>

        <p:column headerText="First Name">
            <h:outputText value="#{user.firstName}"></h:outputText>
        </p:column>

        <p:column headerText="Last Name">
            <h:outputText value="#{user.lastName}"></h:outputText>
        </p:column>
    </p:dataTable>
    <p:commandButton actionListener="#{teamMaintainanceController.check}" ajax="true"/>
</h:form>
</p:dialog>

Now It takes Team Name, A description, A project from the list. Then we are supposed to click on a button that opens a dialog box which has a datatable with multiple rows selection option and a submit button which will submit and save the list in a variable and then the form behind the modal box can be clicked and the entire data at once.

private List<UserDto> userList_ALL;
    private UserDto selectedUsers[];


    public UserDto[] getSelectedUsers() {
        return selectedUsers;
    }
    public void setSelectedUsers(UserDto[] selectedUsers) {
        System.out.println(selectedUsers[0]);
        this.selectedUsers = selectedUsers;
    }
    public List<UserDto> getUserList_ALL() throws IOException{
        return userService.getUserList();
    }
    public void setUserList_ALL(List<UserDto> userList_ALL) {
        this.userList_ALL = userList_ALL;
    }

In my addTeam method I basically do System.out.println(selectedUsers[0].getId()); which throws NULL pointer Exception.

In my check() I basically start my conversation using conversation.begin()

Ayush choubey
  • 606
  • 6
  • 23

1 Answers1

0

Retrieve the list values in @postconstruct

Ayush choubey
  • 606
  • 6
  • 23