JSF中,<h:dataTable>中<h:commandLink/>点击失效 jsf本身的问题将user这个bean的作用域改为session或者使用 <h:outputLink 将value属性改为加参数的链接 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 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> 最后再补充一下 可能在有些时候h:commandLink和h:commandButton外层不套h:form也不会报错 但这并不表明这种写法是对的 假如一个页面里有包含多个页面 而其中很多页面都是这样就很有可能报错 而且是否报错跟操作系统也有关 记得有一次我们组内有个人的h:commandLink外就没有套h:form 结果在他32位的机器上并没报错顺利通过(其实通常也应该报错但时候是会通过的 具体原因未知) 结果在64位的服务器上发布时就出了问题 后来经过我们讨论结论是64位的环境可能对于代码要求更加严谨 还有就是最好在程序里每个h:form都有自己的一个唯一的id标识 这样可以避免很多麻烦 源代码是这样的,bean的作用域也为session <h:form> <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:commandLink action="#{user.showTopics}"> <h:outputText value="#{res.viewSubject}"> </h:outputText> </h:commandLink> </h:column> </h:dataTable></h:form> 可是不行! 提交也是需要设置对应的<from-view-id>和<navigation-case>你dataTable所在页面应该没有定义在<from-view-id>内! 肯定设置好了导航规则啊!这似乎是JSF的一个BUG http://blog.csdn.net/pengrg166/archive/2007/01/22/1490174.aspx正解,我就是采用这位大侠的方法解决这个问题的,很好很强大 我也遇到这个问题,后来一点点的吧页面其他的标签都删除,发现在<ui:composition>标签中的就没有反应,不加这个标签就可以,搞的我头大 后台的方法需设置为ActionEvent,如public String getNewsInfo(ActionEvent event) { ExternalContext externalContext = FacesContext.getCurrentInstance() .getExternalContext(); String newsId = (String)externalContext.getRequestParameterMap().get("newsId"); newsBO = newsServer.findNewsById(newsId); return "view_news_info"; } 我也遇到楼下的问题,有<ui:composition>的标签就有问题,能具体说说解决的办法吗?求解 spring JMS 与IBM MQ消息队列的问题 请教个SQL查询 实体对象属性 求和的问题 Help g711用java写的编解码例子 关于Runtime.getRuntime().exec() 加载图片的页面卡 如何用dom4j 来对一个xml进行 解析 Java IO 问题 高分相送 tomcat能支持ejb吗?急需您的明确答复!谢谢(无内容) 如何根据已知数据,使用java来生成柱状图、和曲线图啊 spring源码少spring-cglib-repack-3.1.jar包 xfire webservice 问题 有懂的帮忙看看 axis 如何使用
<h:form id="link">
<h:commandLink action="#{user.showTopics}">
<h:outputText value="#{res.viewSubject}"> </h:outputText>
</h:commandLink>
</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>
<h:form>
<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:commandLink action="#{user.showTopics}">
<h:outputText value="#{res.viewSubject}"> </h:outputText>
</h:commandLink>
</h:column>
</h:dataTable>
</h:form> 可是不行!
这似乎是JSF的一个BUG
正解,我就是采用这位大侠的方法解决这个问题的,很好很强大
public String getNewsInfo(ActionEvent event) {
ExternalContext externalContext = FacesContext.getCurrentInstance()
.getExternalContext();
String newsId = (String)externalContext.getRequestParameterMap().get("newsId");
newsBO = newsServer.findNewsById(newsId);
return "view_news_info";
}