2016-04-14 98 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> 
相关问题