关于richfaces的datatable组件中的<h:commandLink>问题
chinapaul
2009-11-26
在richfaces的datatable中添加<h:commandLink>,我的意图是想通过这个commandLink传递参数到后台,然后实现页面的跳转,但是现在无法进行页面跳转,只能刷新本页的内容,请问有谁碰到这样的问题,如何解决?
|
|
terryzhou
2009-11-26
paste code:
page and bean |
|
chinapaul
2009-11-26
页面内容是:
<h:form> <div class="search-bar"> <label> 公告标题 </label> <label> <h:inputText value="#{noticeListBean.title}"></h:inputText> </label> <label> 开始时间 </label> <label> <h:inputText value="#{noticeListBean.beginDate}" styleClass="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="false"></h:inputText> </label> <label> 结束时间 </label> <label> <h:inputText value="#{noticeListBean.endDate}" styleClass="Wdate" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" readonly="false"> </h:inputText> </label> <label> <a4j:commandButton action="#{noticeListBean.search}" value="查询" reRender="noticelist,sc1"> </a4j:commandButton> </label> </div> <div class="table"> <rich:dataTable id="noticelist" rows="#{noticeListBean.pageSize}" style="width:746px;" columnClasses="textcenter" value="#{noticeListBean.defaultDataModel}" var="notice" > <f:facet name="header"> <rich:columnGroup> <h:column> <h:outputText styleClass="headerText" value="发布者" /> </h:column> <h:column> <h:outputText styleClass="headerText" value="公告标题" /> </h:column> <h:column> <h:outputText styleClass="headerText" value="发布时间" /> </h:column> <h:column> <h:outputText styleClass="headerText" value="删除" /> </h:column> <h:column> <h:outputText styleClass="headerText" value="修改"/> </h:column> <h:column> <h:outputText styleClass="headerText" value="查看" /> </h:column> </rich:columnGroup> </f:facet> <h:column> <h:outputText value="#{notice.user.userName}" /> </h:column> <h:column> <h:outputText value="#{notice.noticeName}" /> </h:column> <h:column> <h:outputText value="#{notice.publishTime}" /> </h:column> <h:column> <a4j:commandLink id="deletedcmd" value="" action="#{noticeListBean.delete}" reRender="sc1,noticelist" onclick="if(!confirm('是否要真的删除?此操作不可恢复')){return false;}"> <h:graphicImage value="img/hr.gif"></h:graphicImage> <f:param value="#{notice.noticeId}" name="noticeId"></f:param> </a4j:commandLink> </h:column> <h:column> <h:graphicImage value="img/edit-icon.gif"></h:graphicImage> </h:column> <h:column> <h:commandLink action="#{noticeListBean.detailQuery}" value="查看"> <f:param value="#{notice.noticeId}" name="noticeId"></f:param> </h:commandLink> </h:column> </rich:dataTable> <rich:datascroller align="center" for="noticelist" maxPages="20" page="#{noticeListBean.scrollerPage}" id="sc1" reRender="noticelist" /> <a4j:keepAlive beanName="noticeListBean"/> </div></h:form> Bean的代码: public class NoticeListBean extends PageListBaseBean{ private NoticeService noticeService ; private String title; private Date beginDate; private Date endDate; private Notice detailNotice; @Override public PagedListDataModel getDefaultDataModel() { if (defaultDataModel == null ) { defaultDataModel = new PagedListDataModel(pageSize) { public DataPage fetchPage(int startRow, int pageSize) { ValueAdapter total = new ValueAdapter(); List list = null; list = noticeService.queryNotices(null, title, startRow, pageSize, beginDate, endDate, total); return new DataPage(total.getValue(), startRow, list) ; } }; } return defaultDataModel; } public String search(){ this.defaultDataModel = null; getDefaultDataModel(); defaultDataModel.refresh(); return null; } public String delete(){ String noticeId = (String)BaseBean.getRequest().getParameter("noticeId"); noticeService.delNotice(noticeId); defaultDataModel.refresh(); return null; } public String detailQuery(){ String noticeId = BaseBean.getRequest().getParameter("noticeId"); System.out.println(noticeId); if(noticeId==null || "".equals(noticeId.trim())) return "error"; else{ detailNotice = noticeService.findById(noticeId.trim()); return "go_detail"; } } public void setNoticeService(NoticeService noticeService) { this.noticeService = noticeService; } public String getTitle() { return title; } public void setTitle(String title) { this.title = title; } public Date getBeginDate() { return beginDate; } public void setBeginDate(Date beginDate) { this.beginDate = beginDate; } public Date getEndDate() { return endDate; } public void setEndDate(Date endDate) { this.endDate = endDate; } public Notice getDetailNotice() { return detailNotice; } public void setDetailNotice(Notice detailNotice) { this.detailNotice = detailNotice; } } 页面导航: <navigation-rule> <from-view-id>/notice/noticeList.jsp</from-view-id> <navigation-case> <from-outcome>go_detail</from-outcome> <to-view-id>/notice/noticeDetail.jsp</to-view-id> </navigation-case> <navigation-case> <from-outcome>error</from-outcome> <to-view-id>/error/error.jsp</to-view-id> </navigation-case> </navigation-rule> 我现在想通过另外一个页面查看公告的详情,后台的action方法是可以执行,但是页面就是无法跳转 |
|
terryzhou
2009-11-26
我写了个DEMO,可以跳转
1.你地址"/notice/noticeList.jsp"写的对不对,后缀jsp 还是 xhtml? 2.把form里面tag都删了,就留个 <h:commandLink action="#{noticeListBean.detailQuery}" value="查看"> <f:param value="#{notice.noticeId}" name="noticeId"></f:param> </h:commandLink> 再试下,如果可以再把其它TAG一部份一部份还原回去 |
|
chinapaul
2009-11-26
问题解决了,是自己粗心造成的,导航规则出了点小错误,还是谢谢你的热心帮助
|
相关讨论
相关资源推荐
- php zend engine,PHP 5/Zend Engine 2.0的改进(二) (转)
- PHP的核心Zend Engine
- linux php-5.3.28版本升级到php-5.5.25
- php zend engine,PHP5/ZendEngine2的改进
- RichFaces-jsf,a4j,rich项目中总结的标签说明
- RichFaces的rich:dataTable组件内action actionListener不能使用
- Richfaces 文档
- RichFaces JSF自定义分页组件(简洁版)
- 从Richfaces 4.5迁移到Primefaces 6.2
- richfaces组件的使用