• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Model driven validation

 
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have an action that implements com.opensymphony.xwork2.ModelDriven and I cannot get it to accept a date input from date picker on my JSP. I cant figure out where the default validation runs from or what date format is expected. My bean, action and view are shown below.



=========================
Action
==========================

public class AddMember extends ActionSupport implements ModelDriven {

private static final long serialVersionUID = 1L;
Member member = new Member();

public Object getModel() {
// TODO Auto-generated method stub
return member;
}

public void setMember(Member m){
this.member = m;
}

public Member getMember(){
return this.member;
}

public String execute(){
try{
member = new MemberService().saveMember(member);
return SUCCESS;
}catch(Exception e){
e.printStackTrace();
return ERROR;
}
}
}

=================
Model
=================
public class Member implements java.io.Serializable {

private Integer id;
private String firstName;
private String middleName;
private String lastName;
private Date dateOfBirth;
private Date dateOfMembership;

public Member() {
}

public Member(String firstName, String middleName, String lastName,
Date dateOfBirth, Date dateOfMembership) {
this.firstName = firstName;
this.middleName = middleName;
this.lastName = lastName;
this.dateOfBirth = dateOfBirth;
this.dateOfMembership = dateOfMembership;
}

public Integer getId() {
return this.id;
}

public void setId(Integer id) {
this.id = id;
}

public String getFirstName() {
return this.firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public String getMiddleName() {
return this.middleName;
}

public void setMiddleName(String middleName) {
this.middleName = middleName;
}

public String getLastName() {
return this.lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public Date getDateOfBirth() {
return this.dateOfBirth;
}

public void setDateOfBirth(Date dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}

public Date getDateOfMembership() {
return this.dateOfMembership;
}

public void setDateOfMembership(Date dateOfMembership) {
this.dateOfMembership = dateOfMembership;
}

}


===============
view
================

<s:form action="addMember">
<s:textfield name="firstName" label="First Name" value="" />
<s:textfield name="middleName" label="Middle Name" value="" />
<s:textfield name="lastName" label="Last Name" value="" />
<sj:datepicker value="3-23-70" id="dateOfBirth" name="dateOfBirth"
displayFormat="m-dd-yy" label="Date of Birth" changeYear="true" yearRange="-100"/>
<sj:datepicker value="today" id="dateOfMembership"
name="dateOfMembership" displayFormat="m-dd-yy" changeYear="true" yearRange="-30"
label="Date Of Membership" />
<s:submit />

</s:form>






The form will never submit regarless of the date format I try on my date pickers. It comes back with an error saying "Invalid field value for field " for both date fields. Any help will be appreciated
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I changed from ModelDriven action to a simple action as a work around and the dates picked are never submitted to my action. I'm now using xml validation, the validator things that the date fields are blank.
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody here? When I use the date formate dd/mm/yy I dont get the "invalid data for field" error but my xml validation still thinks no dates were submitted. Also I have used "get" for my form method so I can see if the date is indeed getting submited and yes they are being submitted. However this is how the submitted dates look like

member.dateOfBirth=02%2F03%2F1977&member.dateOfMembership=04%2F01%2F2011

Any ideas whats going on with this date picker/validation.
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I managed to fix my error but...my action wont forward. I fixed it by ignoring any xml validation, the date picker accepts date format mm/dd/yy
 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,

I want to use datepicker in my app.


My JSP:


<!DOCTYPE link PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlx.css">
<script src="codebase/dhtmlx.js" type="text/javascript"></script>
<script src="JS/DateValidation.js" type="text/javascript"></script>

<sx:head />
<sj:head />
</head>

<div style="width=100%;" align="center" >
<div ><h2>Add Manager Interest</h2></div>


<s:form action="CreateManagerInterest" namespace="/" method="POST" theme="simple" name="ManagerInterestBean">

<table width="50%" >
<tr>
<td align="left"><s:label value= "Manager*:"/></td>
<td align="left">
<s:url id="managerslist" action="ManagersAutoCompleter" />
<sx:autocompleter name="mgrIntrstBean.manager" href="%{managerslist}" loadOnTextChange="true" loadMinimumCount="1"
cssClass="dhxlist_txt_textarea" dropdownHeight="150px" forceValidOption="true" required="true"/>
</td>
</tr>
<tr>
<td align="left"><s:label value= "Trader:"/></td>
<td align="left">
<s:url id="traderslist" action="TradersAutoCompleter" />
<sx:autocompleter name="mgrIntrstBean.trader" href="%{traderslist}" loadOnTextChange="true" loadMinimumCount="1"
cssClass="dhxlist_txt_textarea" dropdownHeight="150px" forceValidOption="true"/>
</td>
</tr>

<tr>
<td align="left"><s:label value= "Good Until:"/></td>
<td align="left">
<sj:datepicker name="mgrIntrstBean.expiry" displayFormat="MM/dd/yyyy"/>

</td>

</tr>

<tr>
<td align="center" colspan="2"><s:submit value="Submit" align="center" /></td>
</tr>

</table>
</s:form>

</div>
</body>
</html>

I downloaded the jar struts2-jquery-plugin-2.5.3.jar

when I run the app I get the below error

org.apache.jasper.JasperException: /interestInputScreen.jsp(162,8) The sj:datepicker tag declares that it accepts dynamic attributes but does not implement the required interface
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:802)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:865)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)


Please help me

Thanks


 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pooja par wrote:Hi All,

I want to use datepicker in my app.


My JSP:


<!DOCTYPE link PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%>
<%@taglib prefix="sj" uri="/struts-jquery-tags"%>
<html>
<head>
<link rel="STYLESHEET" type="text/css" href="codebase/dhtmlx.css">
<script src="codebase/dhtmlx.js" type="text/javascript"></script>
<script src="JS/DateValidation.js" type="text/javascript"></script>

<sx:head />
<sj:head />
</head>

<div style="width=100%;" align="center" >
<div ><h2>Add Manager Interest</h2></div>


<s:form action="CreateManagerInterest" namespace="/" method="POST" theme="simple" name="ManagerInterestBean">

<table width="50%" >
<tr>
<td align="left"><s:label value= "Manager*:"/></td>
<td align="left">
<s:url id="managerslist" action="ManagersAutoCompleter" />
<sx:autocompleter name="mgrIntrstBean.manager" href="%{managerslist}" loadOnTextChange="true" loadMinimumCount="1"
cssClass="dhxlist_txt_textarea" dropdownHeight="150px" forceValidOption="true" required="true"/>
</td>
</tr>
<tr>
<td align="left"><s:label value= "Trader:"/></td>
<td align="left">
<s:url id="traderslist" action="TradersAutoCompleter" />
<sx:autocompleter name="mgrIntrstBean.trader" href="%{traderslist}" loadOnTextChange="true" loadMinimumCount="1"
cssClass="dhxlist_txt_textarea" dropdownHeight="150px" forceValidOption="true"/>
</td>
</tr>

<tr>
<td align="left"><s:label value= "Good Until:"/></td>
<td align="left">
<sj:datepicker name="mgrIntrstBean.expiry" displayFormat="MM/dd/yyyy"/>

</td>

</tr>

<tr>
<td align="center" colspan="2"><s:submit value="Submit" align="center" /></td>
</tr>

</table>
</s:form>

</div>
</body>
</html>

I downloaded the jar struts2-jquery-plugin-2.5.3.jar

when I run the app I get the below error

org.apache.jasper.JasperException: /interestInputScreen.jsp(162,8) The sj:datepicker tag declares that it accepts dynamic attributes but does not implement the required interface
at org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
at org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
at org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:802)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:865)
at org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Node$Visitor.visitBody(Node.java:2411)
at org.apache.jasper.compiler.Node$Visitor.visit(Node.java:2417)
at org.apache.jasper.compiler.Node$Root.accept(Node.java:495)
at org.apache.jasper.compiler.Node$Nodes.visit(Node.java:2361)
at org.apache.jasper.compiler.Validator.validateExDirectives(Validator.java:1763)
at org.apache.jasper.compiler.Compiler.generateJava(Compiler.java:198)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:347)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:327)
at org.apache.jasper.compiler.Compiler.compile(Compiler.java:314)
at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:592)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:326)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:416)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Unknown Source)


Please help me

Thanks






What struts version? With struts 2.2.2.1 all you need is <%@taglib prefix="sj" uri="/struts-jquery-tags"%>
Struts-dojo-tags are deprecated. The jar you downloaded is all you need besides the tag above. Try deleting

<%@ taglib prefix="sx" uri="/struts-dojo-tags"%> and see what happens.
 
pooja par
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Samson

Thank you for the reply.
I am using struts2-core-2.0.14.jar.
Do I need to update to struts 2.2.2.1 if I need to use jQuery date picker(ofcourse removing dojo tags)

Please suggest me.
 
pooja par
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI Samson

After replacing the struts2-core-2.0.14.jar with struts2-core-2.2.1.1.jar in my project it shows warning messages for all s:form, s:(tags)
is there anyting that I need to replace.
Please help me.
 
pooja par
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Samson,

Thank you soooooo.. much for the reply.
Issue got resolved

Thanks
 
Samson Mlati
Ranch Hand
Posts: 41
Hibernate Oracle Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

pooja par wrote:Hi Samson,

Thank you soooooo.. much for the reply.
Issue got resolved

Thanks



Yay!
 
pooja par
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Samson,

I need struts2 jquery autocompleter for JSON example.

I used below link as reference.. but that is not clear and also not wotking
I see

but nowhere "term is specified in ui-sj:autocompleter"

http://code.google.com/p/struts2-jquery/wiki/AutocompleterTag

Can you please help be in providing me a complete example
 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Pooja par,

i struck at same issue please help me with your solutions on this.

Issue : org.apache.jasper.JasperException: /login.jsp(31,11) The s:form tag declares that it accepts dynamic attributes but does not implement the required interface
org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:40)
org.apache.jasper.compiler.ErrorDispatcher.dispatch(ErrorDispatcher.java:407)
org.apache.jasper.compiler.ErrorDispatcher.jspError(ErrorDispatcher.java:148)
org.apache.jasper.compiler.Validator$ValidateVisitor.visit(Validator.java:802)
org.apache.jasper.compiler.Node$CustomTag.accept(Node.java:1530)

Thanks
Nag
 
I wasn't selected to go to mars. This tiny ad got in ahead of me:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic