日期:2014-05-16  浏览次数:20400 次

Donuts-spring2+hibernate3+jsf开发日志(2)

??? 1-20)tomhowk1.1.3和trinidad1.0.1混用的时候发生冲突,<t:datatable> 翻页的链接不能正常显示,必须取消faces-config.xml文件中的trinidad的renderkit标签
??<!-- Use the Trinidad RenderKit
???? ??<default-render-kit-id>
???? ??? org.apache.myfaces.trinidad.core
?? ??? </default-render-kit-id>
??? ?? -->
??? 1-21)jsf传递参数显示格式化。<h:outputformat> <h:param/></h:outputformat>
??? 1-22)<f:attribute value="left" name="align" />可以设置父对象属性。
?????????????????????? <h:column id="column2">
???????????????????????????? <f:facet name="header">
?????????????????????????????????? <h:outputText styleClass="outputText" value="Alias" id="text3"></h:outputText>
???????????????????????????? </f:facet>
???????????????????????????? <h:outputText id="text4" value="#{varfcBarcelona.alias}"
?????????????????????????????????? styleClass="outputText">
???????????????????????????? </h:outputText>
???????????????????????????? <f:attribute value="left" name="align" />
?????????????????????? </h:column>
??? 1-23)各行中引用t:dataTable的行号? 设置属性:rowIndexVar="rowId"? 用例:index="#{rowId}"
??? 1-24)jsf在datatable页面中点击某条记录编辑时,faces-config.xml中的数据导航不能是redirect跳转,否则编辑页面不能获得编辑对象的id等参数
??? 1-25)MyFaces installation :make sure that there is no jsf-api.jar or jsf-impl.jar
??(i.e. Suns API and implementation) 使用myface的jsf1.2核心时,需要清除jsf-api.jar,jsf-impl.jar 并且bean全部重新编译一下。???问题依旧。
??????????????? 后来,重新定义了myeclipse里的preference配置,在javaee5里清除jsf-api.jar,jsf-impl.jar这两个包。项目重新编译,ok 运行错误NoClassDefFoundError: com.sun.faces.taglib.jsf_core.ViewTag不再出现。问题解决,到此为止。他妈的自欺欺人,那两个jar竟然还在lib目录里,去掉问题还在。
?????????? 1-26)删除操作时,记录仍然会显示在页面上,需要设置一下faces-config.xml 就是删除操作后是redirect到本datapata页面。
??? 1-27)在 Backing Bean 中有这样的一个方法:
??public? String query()
??{
?? dataModel.setWrappedData(getDataPage( 0 , getPageSize()));
??? return?? " success " ;
??}
??只是把数据清空,并强制 PagedListDataModel 读取数据,然后我们返回相同的页面,

?? 1-28)You have a classic case of LIE - Lazy Initialization error. This topic has been discussed so many times that I suggest to do a search on the forum and point to the hibernate documentation. Basically, you are using lazy relationships that require an open session (so the lazy loading can happen). Inside Spring you can use OpenSessionInViewFilter/Interceptor or the HibernateInterceptor to keep a Hibernate session open during a request or method calls.

?? 1-29)Hi,guoshiguan 对于第一个问题,JSF是可以通过Tag的binding属性来动态生成UI组件的JSP: 代码
??<h:panelGroup id="dynamicGroup" binding="#{dynaHandler.dynamicPanelGroup}"></h:panelGroup>?
??Java code
??代码
??private HtmlPanelGroup panelGroup;??
??public HtmlPanelGroup getDynamicPanelGroup(){??
??????? ?Application application = FacesContext.getCurrentInstance().getApplication();??
??????? ?if (this.panelGroup == null) {??
??????????? ??this.panelGroup = (HtmlPanelGroup) application??
??????????????? ???? .createComponent(HtmlPanelGroup.COMPONENT_TYPE);??
??????? ?}??
??????? ?List children = this.panelGroup.getChildren();??
??????? ?children.clear();??
?????? ?? HtmlOutputText outputText = (HtmlOutputText) application??
?????? ???????? .createComponent(HtmlOutputText.COMPONENT_TYPE);??
???? ?? ? outputText.setValue("JSF");??
??children.add(outputText);??
??return this.panelGroup;??
??}
??这样就可以在页面中动态生成一段Text文本

???????? 1-30)<rtexprvalue>true<rtexprvalue/>指明tld tag 属性值是否必须接受EL表达式,如果设成true则必须接受EL表达式,否则跑出错误,当然也可以在代码里判断来避免错误。

? 1-31)jsf-tag自定义问题终于解决了,!!!!!在tld里多一句话:害死人啊!!!!<jsp-version>2.1</jsp-version>
??if you migrate from jsf 1.1 to jsf 1.2, you have got to do this with your whole application.
??just