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

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

?1-49)碰到 用dao.load(class,id)出错,提示延迟加载proxy已经关闭,而用dao.get(class,id)没错,难道spring这个getHibernateTemplate().load方法还需要OpenSessionInViewFilter来支持?后来发现并非如此,是因为spring事务拦截中需要配置load*方法的只读属性,不然spring事务中不会让没有配置的方法读取数据的。

?1-50)JSF Core Library中大部分Tag都有rendered这样的属性,这个属性用来控制该组件是否输出,我们只要把原先
??写在<c:if>中的判断表达式放到这里面就可以达到和<c:if>控制输出一样的效果了。
??<h:dataTable id="myTable" value="#{backingBean.myList}" var="item"
??rendered="#{not empty backingBean.myList}">
??……
??</h:dataTable>
?1-51)EL 表达式? #{not empty myBean.List}

?1-52)这样的标签也支持:<f:verbatim><input type="checkbox" name="chk" value="</f:verbatim><h:outputText value="#{example_messages['date_comp_text3']}"/><f:verbatim> "></f:verbatim>

??????? 1-53)trinidad1.2.1需要设置faces-config.xml的application的renderkit才能正常显示。

?1-54)看来spring接口式编程变得非常重要,只有老老实实按照规范实现接口
??(dao interface,service interface),spring事务处理才大有作为。
??不然事务管理中会导至:OpenSessionInViewFilter(延迟加载就是通过这个代理实现
??的),aop配置等运行运行出错。。

?1-55)myeclipse的refractor和source代码修改工具真是太好用了,有了他,spring编程才变得有乐趣。。。。:)
??1)其中的从class里抽出interface,
??2)把自己原生方法变成继承方法;
??3)把自己原生方法下放给继承自己的类而自己变成抽象方法;
??4)把变量生成getter/setter;
??5)或者把成员的方法代理出来变成自己的方法;
??6)更名,移动目录等功能简直是太好用了。。伟大的工具啊,原来版本jbuilder没带来这么多好处。

?1-56)myeclipse创建bean时,有个Enclosing type 选项,表示创建成为Enclosing type bean的子类

?1-57)> sun未来改进<f:selectItems value="#{someBean.branches}" var="branch" itemValue="#{branch.branchCd}" itemLabel="#{branch.branchLabel}"/>

?1-58)代码收藏:
??<c:forEach var="role" items="#{userForm.userRoles}" varStatus="status">
?????????????? ${role}<c:if test="${!status.last}">,</c:if>
?????????????? <input type="hidden" name="userForm:userRoles" value="${role}" />
?????????? ?</c:forEach>
?1-59)<h:outputText?? value="#{backend.tableUsers.rowIndex?? +?? 1}"?? />?? 这个方法能自动生成行号.

?1-60)selectManyListBox? binding示例:
?My bean code is as below:
?public UIComponentBase getUserGroupsList(){
?EntityManager em = getEntityManager();
?listUserGroup = (List <UserGroup>) em.createQuery("select o from UserGroup as o").getResultList();
?list=new UISelectMany();
?System.out.println("sizeof list:"+listUserGroup.size());

?SelectItem item = new SelectItem();
?for(UserGroup x : listUserGroup) {
?item = new SelectItem(x);

?UISelectItem uiItem = new UISelectItem();
?uiItem.setValue( item );

?list.getChildren().add( uiItem );
?}
?return list;
?}

?The web page code :
?<h:outputText value="User Group Assigned:"/>
?<h:selectManyListbox binding="#{user.userGroupsList}">
------------------------
I understand that that is typically a solution...but it does not get rid of
the "Validation Error: Value is not valid" problem I'm having. My equals
method (below) is similar to the one you provided. However, what appears to
be happening is that on submit of a UISelectMany or UISelectOne component
(such as selectManyListbox), is that every submitted object is compared to
the original list of selectable objects; obviously, the equals method will
only return true one for each of the submitted objects, and false for as
many other selectable objects as are in the original selectable list.

As long as the submitted values are part of the original list, why am I
getting this "Validation Error: Value is not valid" message? Is there
something else I should be doing, or questioning?

??1-61)jsf页面也能直接调用springbean对象,
??1)jsf标签的中比如#{springbean.property},太好了,不用每次都去backingbean一次。这个调用没问题
??2)jstl标签中 <c:out value="${teamService}"></c:out>?? ${springbean.property} ,jstl不能操作jsf和spring环境,调用有问题。

?1-62)多对多关系中,不