You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Wendy Smoak <We...@asu.edu> on 2002/11/05 21:18:48 UTC

Dates & validation

Do most people allow users to type in a complete free-form text date?  Or do
you give them three boxes where they must put in month day and year
separately?

I'm trying to come to terms with validation.  I can't turn on the automatic
validation <action validate="true" ... > because the users are allowed to
leave the form before it's complete and come back to it.  Will I still be
able to use the plug-in Validator?  (All the actions in the struts-validator
example have 'validate' this turned on. :(

I have the DAO layer that takes an internal format date (# of days since
1960-something) to my Value Object which now has a java.sql.Date:
contactVO.setActualDate( java.sql.Date.valueOf( uSession.oconv(
udArray.extract( 16 ), "D4-YMD" ).toString() ) );

But here's where I get lost.  In order to copy the properties back and forth
from Value Object to ActionForm, the types have to match.  (Don't they?) But
if I put a java.sql.Date into my ActionForm, then it will blow up when the
user types 7/13/1985 rather than 1985-07-13 and submits the form.

So, I need a String property in the ActionForm, and ... some special
something that turns it into a java.sql.Date but will not blow up if the
input is wrong?

I'm going in circles.  Any advice is appreciated!  (Should I not be using
java.sql.date?)  I did search for 'struts date validation' with Google, but
didn't find an answer.

-- 
Wendy Smoak
Applications Systems Analyst, Sr.
Arizona State University PA Information Resources Management

Re: Adding a parameter to a URL + can I use the JSTL expression language with struts?

Posted by Antoni Reus <an...@wanadoo.es>.
Hi,

Why don't you just use an input of type hidden?

If you are using an ActionForm add the property objID and use

	<html:hidden property="objID" />

if not then you can just use
	
	<input type="hidden" name="objID" value="${param.objID}">


A Dimecres 06 Novembre 2002 07:03, Jim Collins va escriure:
> Sorry to be a pain but has anyone got any idea how to fix this problem?
> Also can I use the JSP expression language with struts?
>
> Thanks
>
> Jim
>
> > Hi,
> >
> > I have a JSP called upload.jsp with a form and file tag like this:
> >
> > <html:form action="/uploadAction.do" enctype="multipart/form-data">
> >     Please Input The File You Wish to Upload:<br/>
> >   <html:file property="myFile"/><br />
> >   <html:submit />
> > </html:form>
> >
> > The page that calls upload.jsp also passes a parameter called objID, I
>
> would
>
> > like to add this parameter to the action URL but I don't know how to.
> >
> > I did try using a normal html form tag and jstl to add the paramerer like
> > this:
> >
> > <c:url value="/uploadAction.do" var="myUrl">
> >     <c:param name="objID" value ="${param.objID}"/>
> > </c:url>
> >
> > <form action=<c:out value="${myUrl}"/>>
> >     <!--same code as above -->
> > </form>
> >
> > This sets the correct action url in the generated html but I get a bean
> > utils exception when I press the submit button.
> >
> > Any help would be appreciated.
> >
> > Thanks
> >
> > Jim.
> >
> > PS I don't want to use a scriptlet if I can help it. I have seen previous
> > postings from Craig where he advises against using scriptlets.
> >
> >
> > --
> > To unsubscribe, e-mail:
>
> <ma...@jakarta.apache.org>
>
> > For additional commands, e-mail:
>
> <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Adding a parameter to a URL + can I use the JSTL expression language with struts?

Posted by Jim Collins <ja...@blueyonder.co.uk>.
Thanks David,

I'll check that out.

Jim.
----- Original Message -----
From: "David M. Karr" <dm...@earthlink.net>
To: <st...@jakarta.apache.org>
Sent: Wednesday, November 06, 2002 6:53 AM
Subject: Re: Adding a parameter to a URL + can I use the JSTL expression
language with struts?


> >>>>> "Jim" == Jim Collins <ja...@blueyonder.co.uk> writes:
>
>     Jim> Sorry to be a pain but has anyone got any idea how to fix this
problem? Also
>     Jim> can I use the JSP expression language with struts?
>
> If you are using the nightly build, you can use the contributed Struts-EL
> library, along with the JSTL (and Struts itself).  The Struts-EL library
is a
> "port" of the Struts tag library, where the attribute values are evaluated
with
> the JSTL EL engine, instead of runtime scriptlets.  Search the struts-user
list
> for "Struts-EL" for more information about this.  There is a very small
set of
> documentation in the user's guide on Struts-EL (in the nightly build).
>
> Using Struts-EL, it seems concievable (I haven't tried this, specifically)
you
> could do this:
>
>  <c:url value="/uploadAction.do" var="myUrl">
>   <c:param name="objID" value ="${param.objID}"/>
>  </c:url>
>
>  <html-el:form action="${myUrl}">
>   ...
>  </html-el:form>
>
> --
> ===================================================================
> David M. Karr          ; Java/J2EE/XML/Unix/C++
> dmkarr@earthlink.net
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Adding a parameter to a URL + can I use the JSTL expression language with struts?

Posted by "David M. Karr" <dm...@earthlink.net>.
>>>>> "Jim" == Jim Collins <ja...@blueyonder.co.uk> writes:

    Jim> Sorry to be a pain but has anyone got any idea how to fix this problem? Also
    Jim> can I use the JSP expression language with struts?

If you are using the nightly build, you can use the contributed Struts-EL
library, along with the JSTL (and Struts itself).  The Struts-EL library is a
"port" of the Struts tag library, where the attribute values are evaluated with
the JSTL EL engine, instead of runtime scriptlets.  Search the struts-user list
for "Struts-EL" for more information about this.  There is a very small set of
documentation in the user's guide on Struts-EL (in the nightly build).

Using Struts-EL, it seems concievable (I haven't tried this, specifically) you
could do this:

 <c:url value="/uploadAction.do" var="myUrl">
  <c:param name="objID" value ="${param.objID}"/>
 </c:url>
 
 <html-el:form action="${myUrl}">
  ...
 </html-el:form>

-- 
===================================================================
David M. Karr          ; Java/J2EE/XML/Unix/C++
dmkarr@earthlink.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Adding a parameter to a URL + can I use the JSTL expression language with struts?

Posted by Jim Collins <ja...@blueyonder.co.uk>.
Sorry to be a pain but has anyone got any idea how to fix this problem? Also
can I use the JSP expression language with struts?

Thanks

Jim

> Hi,
>
> I have a JSP called upload.jsp with a form and file tag like this:
>
> <html:form action="/uploadAction.do" enctype="multipart/form-data">
>     Please Input The File You Wish to Upload:<br/>
>   <html:file property="myFile"/><br />
>   <html:submit />
> </html:form>
>
> The page that calls upload.jsp also passes a parameter called objID, I
would
> like to add this parameter to the action URL but I don't know how to.
>
> I did try using a normal html form tag and jstl to add the paramerer like
> this:
>
> <c:url value="/uploadAction.do" var="myUrl">
>     <c:param name="objID" value ="${param.objID}"/>
> </c:url>
>
> <form action=<c:out value="${myUrl}"/>>
>     <!--same code as above -->
> </form>
>
> This sets the correct action url in the generated html but I get a bean
> utils exception when I press the submit button.
>
> Any help would be appreciated.
>
> Thanks
>
> Jim.
>
> PS I don't want to use a scriptlet if I can help it. I have seen previous
> postings from Craig where he advises against using scriptlets.
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Adding a parameter to a URL

Posted by Jim Collins <ja...@blueyonder.co.uk>.
Hi,

I have a JSP called upload.jsp with a form and file tag like this:

<html:form action="/uploadAction.do" enctype="multipart/form-data">
    Please Input The File You Wish to Upload:<br/>
  <html:file property="myFile"/><br />
  <html:submit />
</html:form>

The page that calls upload.jsp also passes a parameter called objID, I would
like to add this parameter to the action URL but I don't know how to.

I did try using a normal html form tag and jstl to add the paramerer like
this:

<c:url value="/uploadAction.do" var="myUrl">
    <c:param name="objID" value ="${param.objID}"/>
</c:url>

<form action=<c:out value="${myUrl}"/>>
    <!--same code as above -->
</form>

This sets the correct action url in the generated html but I get a bean
utils exception when I press the submit button.

Any help would be appreciated.

Thanks

Jim.

PS I don't want to use a scriptlet if I can help it. I have seen previous
postings from Craig where he advises against using scriptlets.


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Dates & validation

Posted by Brian Hickey <bh...@r-effects.com>.
Wendy

One vote for three pre-populated boxes. Saves on validation that way :)

Brian

----- Original Message -----
From: "Wendy Smoak" <We...@asu.edu>
To: "'Struts Users Mailing List'" <st...@jakarta.apache.org>
Sent: Tuesday, November 05, 2002 3:18 PM
Subject: Dates & validation


>
> Do most people allow users to type in a complete free-form text date?  Or
do
> you give them three boxes where they must put in month day and year
> separately?
>
> I'm trying to come to terms with validation.  I can't turn on the
automatic
> validation <action validate="true" ... > because the users are allowed to
> leave the form before it's complete and come back to it.  Will I still be
> able to use the plug-in Validator?  (All the actions in the
struts-validator
> example have 'validate' this turned on. :(
>
> I have the DAO layer that takes an internal format date (# of days since
> 1960-something) to my Value Object which now has a java.sql.Date:
> contactVO.setActualDate( java.sql.Date.valueOf( uSession.oconv(
> udArray.extract( 16 ), "D4-YMD" ).toString() ) );
>
> But here's where I get lost.  In order to copy the properties back and
forth
> from Value Object to ActionForm, the types have to match.  (Don't they?)
But
> if I put a java.sql.Date into my ActionForm, then it will blow up when the
> user types 7/13/1985 rather than 1985-07-13 and submits the form.
>
> So, I need a String property in the ActionForm, and ... some special
> something that turns it into a java.sql.Date but will not blow up if the
> input is wrong?
>
> I'm going in circles.  Any advice is appreciated!  (Should I not be using
> java.sql.date?)  I did search for 'struts date validation' with Google,
but
> didn't find an answer.
>
> --
> Wendy Smoak
> Applications Systems Analyst, Sr.
> Arizona State University PA Information Resources Management
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>