2014-02-07 106 views
0

下面是我的listshuttle xhtml其中包含轉換器,以及我已經創建了轉換器,它讀取的值,但是當我嘗試爲特定用戶分配值時,listshuttle的「ValueActionListener」沒有被調用。 請幫我解決這個問題,下面ListShuttle valueActionListener沒有被調用

僅供您參考

<h:form id="listShuttleForm"> 

     <hr align="left" id="h1" style="!important; width: 250px; "/><br /> 
     <rich:listShuttle sourceValue="#{roleAction.availableUserGroupsList}" id="assignUserGroupListShuttleId" 
      targetValue="#{roleAction.assignedUserGroupInfoList}" var="userGroupInfo" listsHeight="300" 
      sourceListWidth="190" targetListWidth="200" sourceCaptionLabel=" #{localeValue.availableUserGroups}" 
      targetCaptionLabel="#{localeValue.assignedUserGroups}" converter="userGroupConverter" 
      valueChangeListener="#{roleAction.assignedUserGroupsListener}" ajaxRendered="true"> 

      <rich:column> 
       <h:outputText value="#{userGroupInfo.groupName}"></h:outputText> 
      </rich:column> 
      <a4j:support event="onlistchanged" reRender="msgId" /> 
      <a4j:support event="onorderchanged" reRender="msgId" /> 
     </rich:listShuttle> 

     </h:form> 

Java代碼的XHTML和Java代碼: -

public String assignedUserGroupsListener(ValueChangeEvent event){ 
    System.out.println("inside assignedUserGroupListenerasdf"); 
    FacesContext fc = FacesContext.getCurrentInstance(); 
    Map<String, Object> sessionMap = fc.getExternalContext().getSessionMap(); 
    HtmlListShuttle listShuttle = (HtmlListShuttle)event.getComponent(); 
    sessionMap.put("assignedUserGroupInfoList", listShuttle.getTargetValue()); 
    return null; 
} 

所有的建議將是非常可觀的。

預先感謝您。

+0

ValueActionListener? – BalusC

回答

0

ValueChangeListener或方法簽名必須匹配

public void valueChangeListener(javax.faces.event.ValueChangeEvent). 

而且你的價值變化監聽不會被解僱,一旦值改變,當你提交表單就會被解僱。所以最好有

<a4j:support event="onlistchanged" 
     actionLisener="#{roleAction.assignedUserGroupsListener}" reRender="msgId" /> 

對於上面的動作監聽器,返回類型也應該是void。

希望這會有所幫助。

+0

我試着用你給的代碼片段,但它仍然不工作... – RaviKiran

+0

你是否改變了方法返回類型爲void? –

+0

是Srikanth ...但我沒有重寫Object類的equals方法...所以它不工作,現在它工作。感謝您的幫助Srikanth – RaviKiran