2016-04-14 61 views
0

我嘗試在單擊commandLink後更新組件面板組,但它不成功。我已經嘗試了很多方法,但沒有任何幫助。請說,我該怎麼做才能更新面板組?點擊後爲什麼不更新面板組?

<h:panelGroup layout="block" id="content"> 
    <h:panelGroup layout="block" id="nav"> 
     <h:form id="itemsMenu"> 
      <h:commandLink value="View" update="workplace" actionListener="#{main.determineAction}"> 
       <f:param name="link" value="Viewing telephone book"/> 
      </h:commandLink> 
     </h:form> 
    </h:panelGroup> 
    <h:panelGroup id="workplace"> 
     <h:panelGroup layout="block" rendered="#{main.responseRendered}"> 
      <ui:include src="#{main.linkPage}"/> 
     </h:panelGroup> 
    </h:panelGroup> 
</h:panelGroup> 

豆代碼:

@ManagedBean(name = "main") 
@ViewScoped public class MainBean implements Serializable { 

private static final long serialVersionUID = 1L; 
private List<String>  listItemsMenu; 
private String   linkPage; 
private boolean   responseRendered = false; 

public boolean isResponseRendered() { 
    return responseRendered; 
} 

public void setResponseRendered(final boolean responseRendered) { 
    this.responseRendered = responseRendered; 
} 

public String getLinkPage() { 
    return linkPage; 
} 

public void setLinkPage(final String linkPage) { 
    this.linkPage = linkPage; 
} 

public void determineAction(final ActionEvent event) { 
    final Locale currentLocale = SessionBean.getCurrentLocale(); 
    final MessageManager messageManager = new MessageManager(currentLocale); 
    final Map<String, String> mapParameters = FacesContext.getCurrentInstance() 
     .getExternalContext().getRequestParameterMap(); 
    final String linkType = mapParameters.get(Constants.ATTRIBUTE_LINK_TYPE); 
    if (linkType.equals(messageManager.getProperty(Constants.MESSAGE_MENU_VIEWING))) { 
    linkPage = Constants.PAGE_VIEW; 
    } 
    ... 
    responseRendered = true; 
    } 
} 

回答

0

玉以及命令的鏈接沒有屬性更新,從而使應該扔在這裏的錯誤:

<h:commandLink value="View" update="workplace"> 

我假設你想要一個阿賈克斯解決方案,它將是:

<h:commandLink value="View"> 
       <f:param name="link" value="Viewing telephone book"/> 
<f:ajax render="workplace" listener="#{main.determineAction}" /> 
      </h:commandLink> 
相關問題