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;
  }
}
4

1 回答 1

0

好吧,命令链接没有属性更新,所以应该在这里抛出错误:

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

我假设你想要一个 ajax 解决方案:

<h:commandLink value="View">
                <f:param name="link" value="Viewing telephone book"/>
<f:ajax render="workplace" listener="#{main.determineAction}" />
            </h:commandLink>
于 2016-04-14T23:12:17.997 回答