我想在我的JSF复合组件中实现一些javas cript,但我有id的问题.我的java脚本:
document.getElementById("myForm:customerId")
Run Code Online (Sandbox Code Playgroud)
不起作用,因为id是错误的.我有JSF复合组件:
<composite:implementation>
<div id="element_customer">
<h2 class="element_title">Customer</h2>
<h:form id="myForm">
<h:inputText id="customerId" value="#{cc.attrs.customerId}"/>
</h:form>
</div>
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)
和HTML输出是:
<div id="element_customer">
<h2 class="element_title">Customer</h2>
<form id="j_idt44:myForm" name="j_idt44:myForm" method="post" ... >
<input type="hidden" name="j_idt44:myForm" value="j_idt44:myForm" />
<input id="j_idt44:myForm:customerId" ... name="j_idt44:myForm:customerId" />
</form>
</div>
Run Code Online (Sandbox Code Playgroud)
为什么HTML输出中使用"j_idt44"?
我仍然不确定正确使用JSF模板和复合组件.我需要创建一个企业Web应用程序,它将拥有大量页面.每个页面都有相同的标题,菜单,页脚,当然还有不同的内容(= JSF模板).每个页面上的内容将由可重复使用的"框"(= JSF复合组件)组成.这些盒子包括一些文件,按钮等.我的解决方案是否合适?或者我应该使用其他技术,如自定义组件,装饰......?
layout.xhtml
<h:body>
<ui:insert name="main_menu">
<ui:include src="/xhtml/template/main_menu.xhtml"/>
</ui:insert>
<ui:insert name="header">
<ui:include src="/xhtml/template/header.xhtml"/>
</ui:insert>
<ui:insert name="content"/>
<ui:insert name="footer">
<ui:include src="/xhtml/template/footer.xhtml"/>
</ui:insert>
</h:body>
Run Code Online (Sandbox Code Playgroud)
customer_overview.xhtml:
<html xmlns:cc="http://java.sun.com/jsf/composite/composite_component">
<h:body>
<!-- Facelet template -->
<ui:composition template="/xhtml/template/layout.xhtml">
<ui:define name="content">
<!-- Composite Components -->
<cc:component_case_history
caseList="#{customerOverviewController.cases}"
/>
<cc:component_customer
....
/>
...
</ui:define>
</ui:composition>
</h:body>
Run Code Online (Sandbox Code Playgroud)
component_case_history.xhtml
<html xmlns:composite="http://java.sun.com/jsf/composite">
<composite:interface>
<composite:attribute name="cases" type="java.util.List"/>
</composite:interface>
<composite:implementation>
<!-- using of "cases" -->
...
</composite:implementation>
Run Code Online (Sandbox Code Playgroud)
CustomerOverviewController.java
@ManagedBean
@ViewScoped
public class CustomerOverviewController {
public List<Case> getCases() {
...
}
}
Run Code Online (Sandbox Code Playgroud)
编辑2012-04-27 …
我正在使用Oracle数据库,我有序列和触发器,用于在插入之前生成和存储ID.
CREATE SEQUENCE CASE_SEQ START WITH 1001 INCREMENT BY 1 NOMAXVALUE;
CREATE OR REPLACE TRIGGER CASE_TR_SEQ
BEFORE INSERT ON CASE FOR EACH ROW
BEGIN
SELECT CASE_SEQ.NEXTVAL INTO :NEW.CASE_ID FROM DUAL;
END;
/
Run Code Online (Sandbox Code Playgroud)
然后我有一个简单的实体与属性:
@Id
@Column(name = "CASE_ID", insertable = false, updatable = false)
private Long caseId;
Run Code Online (Sandbox Code Playgroud)
...当我尝试构建项目时,我得到:
Exception [EclipseLink-46] (Eclipse Persistence Services - 2.3.2.v20111125-r10461):
org.eclipse.persistence.exceptions.DescriptorException
Exception Description: There should be one non-read-only mapping defined for the
primary key field [CASE.CASE_ID].
Run Code Online (Sandbox Code Playgroud)
当我删除可插入或可更新的关键字时,它可以工作.我知道有很多解决方案如何使用JPA生成ID,JPA也可以使用(调用)oracle序列来设置(生成)ID.但我试着理解为什么我的解决方案是错误的.为什么我不能将这两个关键字与@Id注释一起使用?我的想法是:我想禁止JPA插入或更新caseId.
1)什么是正确的洗液?我应该只使用@Id:
@Id
@Column(name = "CASE_ID")
private Long caseId;
Run Code Online (Sandbox Code Playgroud)
或更好(更安全)定义insertable …
我有一个简单的 web 服务服务器,它接收带有 MIME 附件的 SOAP,将它存储到 HashMap 并用这个 mime 附件发回消息:
如果我发送带有小附件(<80MB)的请求,一切正常,但是当我发送带有>80MB 附件的请求时,DataHandler 对象为空。所以它不是从 Request 中解析出来的,也不是存储到 HashMap 中的。我是否启用了 mimepull 无关紧要,如果是,大附件将存储到硬盘驱动器上的临时文件夹中。
启用 MimePull:
-Dsaaj.use.mimepull=true
-Djava.io.tmpdir=/path/to/tmpdir
Run Code Online (Sandbox Code Playgroud)
扩大的 GlassFish 线程池:
"Max Thread Pool Size" from 5 to 32
"Min Thread Pool Size" from 2 …
Run Code Online (Sandbox Code Playgroud) 我需要垂直拆分页面(例如 60%:40%)到两个区域,并且拆分器必须可拖动。所以我选择了 PrimeNG p-splitter。右侧区域包含带有水平滚动条的 p-table(基于文档: https: //www.primefaces.org/primeng/showcase/#/table/scroll部分:“水平和垂直”):
<p-splitter [panelSizes]="[60,40]" [style]="{'height': '400px'}">
<ng-template pTemplate>
<p-table [value]="cars" [scrollable]="true" [style]="{width:'600px'}" scrollHeight="200px">
...
</p-table>
</ng-template>
<ng-template pTemplate>
Panel 2
</ng-template>
</p-splitter>
Run Code Online (Sandbox Code Playgroud)
问题是表格宽度绑定为 600px 并且:
StackBlitz 上的项目
https://stackblitz.com/edit/primeng-splitter-and-datatable
完整代码
<p-splitter [panelSizes]="[60,40]" [style]="{'height': '400px'}">
<ng-template pTemplate>
<p-table [value]="cars" [scrollable]="true" [style]="{width:'600px'}" scrollHeight="200px">
<ng-template pTemplate="colgroup" let-columns>
<colgroup>
<col style="width:250px">
<col style="width:250px">
<col style="width:250px">
<col style="width:250px">
</colgroup>
</ng-template>
<ng-template pTemplate="header">
<tr>
<th>Vin</th>
<th>Year</th>
<th>Brand</th>
<th>Color</th>
</tr>
</ng-template>
<ng-template pTemplate="body" let-car>
<tr>
<td>{{car.vin}}</td>
<td>{{car.year}}</td>
<td>{{car.brand}}</td>
<td>{{car.color}}</td> …
Run Code Online (Sandbox Code Playgroud) java ×2
jsf-2 ×2
angular ×1
attachment ×1
eclipselink ×1
glassfish-3 ×1
jaxb2 ×1
jpa ×1
jpa-2.0 ×1
jsf ×1
soap ×1
spring-ws ×1
tagfile ×1