gpt4 book ai didi

java - 发行日期类型为 f :param

转载 作者:行者123 更新时间:2023-11-29 06:19:58 25 4
gpt4 key购买 nike

我正在尝试按日期和用户 ID 过滤 listPage。从数据表中,选定的用户 ID 和日期值被传递到带有 f:param 标记的 listPage。列表页面显示一条错误消息,指出“值必须是日期”并且筛选器不起作用。如果它只是按没有日期的用户标识过滤,它就可以工作。我做错了什么?或者我怎样才能让它工作?我也尝试过使用 JBoss 接缝日期转换器,但它也不起作用。

这是我的代码:

firstPage.xhtml

<h:column>
<f:facet name="header">Date</f:facet>
<h:outputText value="#{_auditEventFact[3]}">
</h:outputText>
</h:column>



<rich:column styleClass="action">
<f:facet name="header">Action</f:facet>
<s:link value="View" view="/AuditEventFactList.xhtml" action="# auditEventFactList.lookUpUserAuditRecords()}">
<f:param name="userid" value="#{_auditEventFact[1]}"/>
<f:param name="ntimestamp" value="#{_auditEventFact[3]}"/>
</s:link>
</rich:column>

pages.xml

<param name="from"/>
<param name="userid" value="#{auditEventFactList.auditEventFact.userid}"/>
<param name="ntimestamp" value="#{auditEventFactList.auditEventFact.ntimestamp}" converterId="javax.faces.DateTime"/>

ListAction.java

private static final String EJBQL = "select auditEventFact from AuditEventFact auditEventFact";
private static final String[] RESTRICTIONS = {
"lower(auditEventFact.userid) like concat(lower(#{auditEventFactList.auditEventFact.userid}),'%')",
"auditEventFact.ntimestamp = #{auditEventFactList.auditEventFact.ntimestamp}",
"lower(auditEventFact.auditid) like concat(lower(#{auditEventFactList.auditEventFact.auditid}),'%')", };

private AuditEventFact auditEventFact = new AuditEventFact();
public AuditEventFactList() {
setEjbql(EJBQL);
setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
setMaxResults(25);
}

EntityBean.java

   @Temporal(TemporalType.TIMESTAMP)
@Column(name="NTIMESTAMP#", length=11)
public Date getNtimestamp() {
return this.ntimestamp1;
}

public void setNtimestamp(Date ntimestamp1) {
this.ntimestamp1 = ntimestamp1;
}

最佳答案

我不做Seam,所以无法给出针对Seam的回答。但基本上,f:param设置一个 HTTP 请求参数,该参数只能包含字符串,因为它们是按照 HTTP 规范以 ASCII 形式传输的。它没有被作为一个完全有值(value)的 java.util.Date对象如您所料。相反,String.valueOf(date) 的结果被通过了。其格式在 Date#toString() 中指定。 .

用简单的 JSF 术语来说,有两种解决方案:

  1. 使用 <h:commandLink>而是结合 f:setPropertyActionListener它能够将完全有值(value)的非标准 Java 对象作为“参数”“传递”。

    <h:commandLink value="View" action="#{auditEventFactList.lookUpUserAuditRecords}">
    <f:setPropertyActionListener target="#{entityBean.ntimestamp}" value="#{_auditEventFact[3]}"/>
    </h:commandLink>
  2. 使用 String而不是 Datentimestamp或包装另一个 String它周围的 setter 转换 StringDate并代表原始Date二传手。 java.text.SimpleDateFormat 可能对此有所帮助。

看看结合 Seam 是否可行。

关于java - 发行日期类型为 f :param,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3532975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com