日期:2014-05-20  浏览次数:20770 次

JSF中,<h:dataTable>中<h:commandLink/>点击失效
JSF中,<h:dataTable>中<h:commandLink/>点击失效的问题!
源码如下:
<h:dataTable border="1" value="#{views.viewList}" var="res">  
  <h:column id="column1">
  <f:facet name="header">
  <h:outputText value="视图名称"></h:outputText>
  </f:facet>
  <h:commandButton value="#{res.viewSubject}" action="#{user.showTopics}"></h:commandButton>
  <h:commandLink action="#{user.showTopics}">
  <h:outputText value="#{res.viewSubject}"></h:outputText>
  </h:commandLink>
  </h:column>
</h:dataTable>

上面的代码中,用了h:commandButton 和 h:commandLink ,点击h:commandButton可以正确提交,而h:commandLink却没有任何作用,只是刷新本页面!

------解决方案--------------------

jsf本身的问题

将user这个bean的作用域改为session

或者使用 <h:outputLink 将value属性改为加参数的链接
------解决方案--------------------
http://blog.csdn.net/pengrg166/archive/2007/01/22/1490174.aspx
------解决方案--------------------
h:commandLink 是需要 h:form来支持的 外层套个h:form就可以了应该
<h:form id="link">
<h:commandLink action="#{user.showTopics}">
<h:outputText value="#{res.viewSubject}"> </h:outputText>
</h:commandLink>
</h:form>
------解决方案--------------------
h:commandLink和h:commandButton 都是需要 h:form来支持的 外层套个h:form就可以了应该
<h:form id="link">
<h:commandButton value="#{res.viewSubject}" action="#{user.showTopics}"> </h:commandButton> 
<h:commandLink action="#{user.showTopics}">
<h:outputText value="#{res.viewSubject}"> </h:outputText>
</h:commandLink>
</h:form>