2016-06-29 12 views
0

사용자가 다른 사용자를 기준으로 역할을 선택 및 선택 취소하고이를 데이터베이스에 제출하여 업데이트 할 수있는 모달 대화 상자가 있습니다.PrimeFaces ManyCheckbox ArrayList가 모달 대화 상자 내에서 업데이트되지 않습니다.

그러나, 디버깅 후 ManyCheckbox 후위 ArrayList가 업데이트되지 않으며, selectedRolesArrayList이 원래 무엇으로 남아있다. 예를 들어

:

  1. 나는 응용 프로그램을로드

    이 내가이 사용자를 편집하려고 할 역할 '관리자'

  2. 로 데이터베이스에서 한 사용자가하고 대화 상자가 열립니다

  3. 'admin'확인란이 선택됩니다.

  4. 나는 '사용자 역할의 체크 박스를 클릭하고 인 selectedRoles 배열 대신'관리자 '와 여기에 사용자

의 또 단지'관리 '이다

  • 제출 클릭 내 대화 모달 :

    <p:dialog header="Editing User ID: #{usersView.viewUser}" id="editUserDialog" widgetVar="editUserDialog" modal="true" appendTo="@(body)"> 
        <h:form id="editUserForm"> 
         <p:selectManyCheckbox id="roleSelect" value="#{usersView.selectedRoles}" layout="grid" columns="3"> 
          <f:selectItems value="#{rolesView.roles}" var="role" itemLabel="#{role.name}" itemValue="#{role.name}" /> 
         </p:selectManyCheckbox> 
         <p:separator /> 
         <p:commandButton process="@this" update=":form:tabs:adminView:userTable:userRoleOutput" value="Submit" id="EditUserSubmitButton" actionListener="#{usersView.editUserRole}" oncomplete="PF('editUserDialog').hide();" /> 
        </h:form> 
    </p:dialog> 
    

    UserView :

    @ManagedBean(name="usersView", eager=true) 
    @ApplicationScoped 
    
    private ArrayList<String> selectedRoles; 
    
    public Arraylist<String> getSelectedRoles() 
    { 
        return this.selectedRoles; 
    } 
    
    public void setSelectedRoles(ArrayList<String> roles) 
    { 
        this.selectedRoles = roles; 
    } 
    
    public void editUserRole(ActionEvent actionEvent) 
    { 
        // This method literally just loops through all users and matches the one we're looking at 
        User user = findUser(); 
    
        if (user != null) 
        { 
         // gives user checked roles in database and local session 
         addSelectedRoles(user); 
    
         ArrayList<String> rolesToRemove = user.getRoleNames(); 
         rolesToRemove.removeAll(selectedRoles); 
    
         // removes user unchecked roles in database and local session 
         removeSelectedRoles(user, rolesToRemove); 
        } 
    
        else 
        { 
         // Handle exception... 
        } 
    } 
    

    제한된 VM에서 작업 중이므로 복사하여 붙여 넣을 수 없으며 게시 할 수있는 모든 정보입니다. 이는 충분하다고 생각합니다.

    도움을 주시면 대단히 감사하겠습니다.

  • +0

    @ BalusC 내 잘못, stackoverflow 항상 태그로 권장, 나는 미래의 질문이 명심해야합니다. – James

    +0

    백킹 빈 코드를 게시 할 수 있습니까 – Ankit

    +0

    @Ankit 지금 게시했습니다. 도움이되기를 바랍니다. – James

    답변

    0

    process="@this"을 제거하여 내 문제를 해결했으며 이제 ArrayList가 업데이트되고 있습니다.

    process="@this"은 commandLink의 현재 구성 요소이며 따라서 업데이트하지 않는 이유를 의미합니다.