2010-08-20 4 views
1

date 및 userid로 listPage를 필터링하려고합니다. 데이터 테이블에서 선택된 사용자 ID와 날짜 값은 f : param 태그로 listPage에 전달됩니다. 목록 페이지에 "값은 날짜 여야합니다."라는 오류가 표시되고 필터가 작동하지 않습니다. 그것은 그냥 날짜없이 사용자 ID로 필터링 된 경우 작동합니다. 나는 무엇을 잘못 할 수 있 었는가? 또는 어떻게 작동시킬 수 있습니까? 나는 또한 JBoss seam date 변환기를 사용해 보았습니다. Heres는f : param을 사용하여 날짜 유형 전달하기

내 코드 :

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; 
    } 

답변

3

내가 솔기를하지 않기 때문에 나는 심-대상 대답을 줄 수 없습니다. 그러나 기본적으로 f:param은 HTTP 사양에 따라 ASCII 형식으로 전송되기 때문에 문자열 만 포함 할 수있는 HTTP 요청 매개 변수를 설정합니다. 당신이 기대하는 것처럼 그것은 완전한 가치의 java.util.Date 개체로 전달되지 않았습니다. 대신 String.valueOf(date)의 결과가 전달됩니다. 형식은 Date#toString()으로 지정됩니다. 대신 f:setPropertyActionListener와 조합은 "통과"할 수

  1. 사용 <h:commandLink>이 fullworthy 비표준 자바는 "매개 변수"로 객체 : 일반 JSF의 측면에서

    는 두 가지 솔루션이 있습니다.

    <h:commandLink value="View" action="#{auditEventFactList.lookUpUserAuditRecords}"> 
        <f:setPropertyActionListener target="#{entityBean.ntimestamp}" value="#{_auditEventFact[3]}"/> 
    </h:commandLink> 
    
  2. ntimestamp에서 사용 String 대신 Date 또는 원래 Date 세터에 Date 위임에 String 변환 주위 다른 String 세터를 포장. java.text.SimpleDateFormat이 도움이 될 수 있습니다.

Seam과 함께 사용할 수 있는지 확인하십시오.

0

매개 변수에 <s:convertDateTime /> 태그를 사용할 수 있습니까? 나는 그것을 직접 시도한 적이 없지만 찾아 볼만한 가치가있다.

관련 문제