[Tapestry4] Tapestry4.1 使用@For组件显示newsList的问题。
tidus2005
2008-05-09
本人公司项目需要使用Tapestry4.1
需要在页面上显示一个新闻列表: 页面显示: Application Error Some user action caused serious application error. org.apache.tapestry.BindingException: Unable to update OGNL expression '<parsed OGNL expression>' of $Home_0@3c1[Home] to title='Bosch worries about 2009 after U.S. consumer slump';description='U.S. consumers worried about a recession will take a painful toll this year on Bosch Group, a German manufacturer of a wide range of items from car parts to washing machines and power tools.';url='http://www.autonews.com/article/20080508/ANA02/92908385/1193/rss01&rssfeed=rss01';author='null';publicationDate='null': $Home_0.currentNews [context:/Home.page, line 10, column 49] Home.java public abstract class Home extends BasePage { private static final Logger LOGGER = Logger.getLogger(Home.class); @Bean public abstract ValidationDelegate getDelegate(); @InjectObject("spring:newsGrabService") public abstract NewsGrabService getNewsGrabService(); @InjectObject("spring:authenticationService") public abstract AuthenticationService getAuthenticationService(); @InjectObject("spring:sectionService") public abstract SectionService getSectionService(); @InjectObject("engine-service:page") public abstract IEngineService getPageService(); public abstract String getUserName(); public abstract void setUserName(String userName); public abstract String getPassword(); public abstract void setPassword(String password); public abstract String getErrorMessage(); public abstract void setErrorMessage(String errorMessage); /** * Login form action * * @return redirect to Home or dealer.Home page. */ public ILink doLogin() { Authentication authentication; try { authentication = getAuthenticationService().login(getUserName(), getPassword() != null ? getPassword() : ""); } catch (BadCredentialsException e) { getDelegate().record(null, "Authentication failed"); return null; } if (authentication instanceof DealerAuthenticationToken) { return getPageService().getLink(false, "dealer/Home"); } else if (authentication instanceof AdministratorAuthenticationToken) { return getPageService().getLink(false, "admin/Home"); } else { LOGGER.error("Authentication token is not supported: " + authentication); throw new IllegalStateException( "Authentication token is not supported: " + authentication); } } public Section getContent(String id) { return getSectionService().findSection(id); } private List<News> newsList = new ArrayList<News>(); public List<News> getNewsList() { NewsGrabService newsGrabService = getNewsGrabService(); List<News> newses = newsGrabService.getAllCachedNews(); return newses; } public void setNewsList(List<News> newsList) { this.newsList = newsList; } } <table cellpadding="0" cellspacing="0"> <tr jwcid="@For" source="ognl:newsList" value="ognl:news" keyExpression="id" element="tr"> <td> <div class="home-content-panel-air-inner" style="background-color: #FFFFFF"> <b><span jwcid="@Insert" value="ognl:news.title">Test Title</span></b> - <span jwcid="@Insert" value="ognl:news.description">Test description</span>... </div> </td> </tr> </table> <?xml version="1.0"?> <!DOCTYPE page-specification PUBLIC "-//Apache Software Foundation//Tapestry Specification 4.0//EN" "http://tapestry.apache.org/dtd/Tapestry_4_0.dtd"> <page-specification> <asset name="common" path="/css/common.css" /> </page-specification> 特此请教大家! |
|
tidus2005
2008-05-09
请大家帮帮忙! 谢谢!!!!
|
|
tapestry
2008-05-10
有Home.page文件么,贴一下。
还有 # private List<News> newsList = new ArrayList<News>(); # public List<News> getNewsList() { # NewsGrabService newsGrabService = getNewsGrabService(); # List<News> newses = newsGrabService.getAllCachedNews(); # return newses; # } # public void setNewsList(List<News> newsList) { # this.newsList = newsList; # } 这个是什么意思,直接留 public List<News> getNewsList() { NewsGrabService newsGrabService = getNewsGrabService(); List<News> newses = newsGrabService.getAllCachedNews(); return newses; } 这些就可以了,其它的去掉。 |