我很好奇为我的下一个项目完全使用模式导出.我认为它是一种非常有用的方法来真正处理对象而不是底层数据库.只需创建并注释模型,然后将其导出即可.
但是从先创建表格然后再创建模型对象的习惯来看,我对使用模式导出完全有疑问.这主要是因为我真的深入研究了休眠.但我仍然很好奇这个区域列表在使用模式导出时是否会出现问题.请分享你的经历..
谢谢
让我们从一个例子开始:
在我的JPA实体中
public class User {
@Pattern("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$", message="invalidEmailResourceBundleKey")
private String email;
@Min(5, message="minimumResourceBundleKey")
private int age;
...
}
Run Code Online (Sandbox Code Playgroud)
在我的JSF Bean中
public class UserBean {
private User user;
// do i have to redefine it here, since it's already a part of the user ?
@@Pattern("^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$")
public String getEmail() {
return user.getEmail();
}
public void setEmail(String s) {
user.setEmail(s);
}
// do i have to redefine it here, since it's already a part of the user ?
@Min(5, message="minimumResourceBundleKey")
public int …
Run Code Online (Sandbox Code Playgroud) 我目前正在尝试构建一个复合组件,这就是我如何使用我的组件:
包括它 xmlns:albert="http://java.sun.com/jsf/composite/albert"
这是用法示例
<albert:infoButton
infoId="infoSingleRecord"
params="transDateFrom transDateTo"
mappingMethod="#{tBrowseBean_ConfirmedRPB.mapSendInfoSingleRecord}" />
Run Code Online (Sandbox Code Playgroud)
这是放在resources/albert/infoButton.xhtml中的组件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="infoId" required="true" />
<composite:attribute name="params" />
<composite:attribute name="mappingMethod" method-signature="java.lang.String action()" />
</composite:interface>
<composite:implementation>
<p:commandButton
process="@this #{cc.attrs.params}"
actionListener="#{cc.attrs.mappingMethod}"
update="#{cc.attrs.infoId}Panel"
oncomplete="#{cc.attrs.infoId}Dialog.show()"
image="ui-icon ui-icon-search" />
</composite:implementation>
</html>
Run Code Online (Sandbox Code Playgroud)
但运行它,当单击infoButton时,此异常跟踪显示在我的catalina.out日志文件中:
Apr 25, 2011 10:08:43 AM javax.faces.event.MethodExpressionActionListener processAction
SEVERE: Received 'javax.el.PropertyNotFoundException' when invoking action listener '#{cc.attrs.mappingMethod}' for component 'j_idt71'
Apr 25, 2011 10:08:43 AM …
Run Code Online (Sandbox Code Playgroud) 我目前正在使用JSF 2.0中的facelets进行实验.
我目前有一个案例,其中2个facelets使用公共网格定义,仅在bean名称,列表名称,标题,网格id等某些区域有所不同.
所以我的想法是:
<ui:insert>
在使用它的页面之间可能不同的区域<ui:define>
这是我的gridTemplate.xhtml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:fn="http://java.sun.com/jsp/jstl/functions">
<h:head>
<title>#{msgs.title}</title>
</h:head>
<h:body>
<ui:composition template="/template/masterlayout.xhtml">
<p:dataTable id="<ui:insert name='gridId' />" var="rpb"
value="#{<ui:insert name='bean' />.<ui:insert name='list' />}">
<f:facet name="header">
<h3><ui:insert name='title' /></h3>
</f:facet>
.....
<f:facet name="footer">
#{fn:length(<ui:insert name='bean' />.<ui:insert name='list' />)} records<br />
</f:facet>
</p:dataTable>
</ui:composition>
</h:body>
</html>
Run Code Online (Sandbox Code Playgroud)
这是使用网格模板的facelet之一:
<ui:composition template="gridTemplate.xhtml">
<ui:define name="gridId">grid</ui:define>
<ui:define name="bean">myBean</ui:define>
<ui:define name="list">myList</ui:define>
<ui:define name="title">my message !</ui:define>
</ui:composition>
Run Code Online (Sandbox Code Playgroud)
这个实验最终得到: …
我目前正在使用Spring MVC 3.x,并使用freemarker视图解析器.
最近我一直想知道在作为响应发送回来之前将视图翻译成html所需的执行时间.如果这方面的事情很慢,我想做调音,这就是为什么我需要一些数字.
在普通的freemarker模式下,我实际上可以在它们之间执行简单的System.currentTimeMillis()来找出执行时间:
long start = System.currentTimeMillis();
// this could be slow or fast depending on the caching used
Template temp = cfg.getTemplate(ftlName);
...
temp.process(model, myWriter); // depends on the writer
System.out.printf("done in %s ms", System.currentTimeMillis() - start);
Run Code Online (Sandbox Code Playgroud)
但是,当使用spring mvc的freemaker视图渲染时,我该怎么做呢?
jsf ×3
jsf-2 ×3
facelets ×1
freemarker ×1
hibernate ×1
java ×1
jpa ×1
jpa-2.0 ×1
mongodb ×1
mongodb-java ×1
spring-data ×1
spring-mvc ×1