You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Burns <fr...@the-hub.demon.co.uk> on 2004/11/20 13:40:53 UTC

How can I do this ... ?

Hi,

Although I have been using Struts for a while now, I have this new requirement and I don't know an obvious way to implement it. Can anyone please tell me how I can do this?

BACKGROUND: I want to display a list of existing items of a certain type and allow users to edit these and save them. I don't know how long the list is -- it may be one or 100 or any number of items long.

QUESTION: So, how do I write an ActionForm to accept an UNKNOWN number of items? And how do I "dynamically" write the required number of <html:text> tags (appropriately labelled) to be able to accept the values returned from the ActionForm if validation fails?

Thanks,

Frank.

Re: How can I do this ... ?

Posted by Niall Pemberton <ni...@blueyonder.co.uk>.
You can use the validator - specify the indexedListProperty in the
validation.xml

Something like this...


 <field property="skillId" indexedListProperty="skills" depends="...">
    .....
 <field>

Niall


----- Original Message ----- 
From: "Frank Burns" <fr...@the-hub.demon.co.uk>
To: "Struts Users Mailing List" <us...@struts.apache.org>; "Mark Lowe"
<me...@gmail.com>
Sent: Monday, November 22, 2004 2:05 AM
Subject: Re: How can I do this ... ?


> So, in using this solution, must validation of the "generated" <html:text>
> fields be carried out in the validation() method of ActionForm?
>
> Or is there anyway I can use the Struts Validator framework? In which case
> what would be the appropriate elements for the validation.xml file?
>
> Thanks,
>
> Frank.
>
> ----- Original Message ----- 
> From: "Mark Lowe" <me...@gmail.com>
> To: "Struts Users Mailing List" <us...@struts.apache.org>
> Sent: Saturday, November 20, 2004 1:08 PM
> Subject: Re: How can I do this ... ?
>
>
> >I could explain but niall has already documented things here.
> >
> > http://wiki.apache.org/struts/StrutsCatalogLazyList
> >
> > I'd go for the hand cranked option. Its one less dependency and
> > lighter than using lazylist.
> >
> > LazyForm looks pretty cool if you like dynabeans, certainly really
> > good for mocking things up until you get the time to write an
> > actionform.
> >
> > Mark
> >
> > On Sat, 20 Nov 2004 12:40:53 -0000, Frank Burns
> > <fr...@the-hub.demon.co.uk> wrote:
> >> Hi,
> >>
> >> Although I have been using Struts for a while now, I have this new
> >> requirement and I don't know an obvious way to implement it. Can anyone
> >> please tell me how I can do this?
> >>
> >> BACKGROUND: I want to display a list of existing items of a certain
type
> >> and allow users to edit these and save them. I don't know how long the
> >> list is -- it may be one or 100 or any number of items long.
> >>
> >> QUESTION: So, how do I write an ActionForm to accept an UNKNOWN number
of
> >> items? And how do I "dynamically" write the required number of
> >> <html:text> tags (appropriately labelled) to be able to accept the
values
> >> returned from the ActionForm if validation fails?
> >>
> >> Thanks,
> >>
> >> Frank.
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How can I do this ... ?

Posted by Frank Burns <fr...@the-hub.demon.co.uk>.
So, in using this solution, must validation of the "generated" <html:text> 
fields be carried out in the validation() method of ActionForm?

Or is there anyway I can use the Struts Validator framework? In which case 
what would be the appropriate elements for the validation.xml file?

Thanks,

Frank.

----- Original Message ----- 
From: "Mark Lowe" <me...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Saturday, November 20, 2004 1:08 PM
Subject: Re: How can I do this ... ?


>I could explain but niall has already documented things here.
>
> http://wiki.apache.org/struts/StrutsCatalogLazyList
>
> I'd go for the hand cranked option. Its one less dependency and
> lighter than using lazylist.
>
> LazyForm looks pretty cool if you like dynabeans, certainly really
> good for mocking things up until you get the time to write an
> actionform.
>
> Mark
>
> On Sat, 20 Nov 2004 12:40:53 -0000, Frank Burns
> <fr...@the-hub.demon.co.uk> wrote:
>> Hi,
>>
>> Although I have been using Struts for a while now, I have this new 
>> requirement and I don't know an obvious way to implement it. Can anyone 
>> please tell me how I can do this?
>>
>> BACKGROUND: I want to display a list of existing items of a certain type 
>> and allow users to edit these and save them. I don't know how long the 
>> list is -- it may be one or 100 or any number of items long.
>>
>> QUESTION: So, how do I write an ActionForm to accept an UNKNOWN number of 
>> items? And how do I "dynamically" write the required number of 
>> <html:text> tags (appropriately labelled) to be able to accept the values 
>> returned from the ActionForm if validation fails?
>>
>> Thanks,
>>
>> Frank.
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How can I do this ... ?

Posted by Mark Lowe <me...@gmail.com>.
I could explain but niall has already documented things here. 

http://wiki.apache.org/struts/StrutsCatalogLazyList

I'd go for the hand cranked option. Its one less dependency and
lighter than using lazylist.

LazyForm looks pretty cool if you like dynabeans, certainly really
good for mocking things up until you get the time to write an
actionform.

Mark

On Sat, 20 Nov 2004 12:40:53 -0000, Frank Burns
<fr...@the-hub.demon.co.uk> wrote:
> Hi,
> 
> Although I have been using Struts for a while now, I have this new requirement and I don't know an obvious way to implement it. Can anyone please tell me how I can do this?
> 
> BACKGROUND: I want to display a list of existing items of a certain type and allow users to edit these and save them. I don't know how long the list is -- it may be one or 100 or any number of items long.
> 
> QUESTION: So, how do I write an ActionForm to accept an UNKNOWN number of items? And how do I "dynamically" write the required number of <html:text> tags (appropriately labelled) to be able to accept the values returned from the ActionForm if validation fails?
> 
> Thanks,
> 
> Frank.
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Versions of Tomcat Causing Problem with tags?

Posted by Stefan Clos <ma...@gmx.net>.
I think you´re meaning the v. 5.0.28 of Tomcat.

Are all you required packages in your WEB-INF/lib directory of your 
application?
Maybe you have some packages in the TOMCAT_HOME/server/lib of your Tomcat.



cheers,
Stefan

Frank Burns schrieb:

> I am using Struts version 1.2.4 and running identical code on two 
> different platforms:
>
> 1) Tomcat: v2.0.28 on XP
> 2) Tomcat v2.0.19 on linux.
>
> The code on the v2.0.28 runs perfectly. However, on the v2.0.19, the 
> <nested:...> tags are ignored.
>
> Any suggestions as to what might be the source of this problem?
>
> I am finding this VERY frustrating :-(
>
> Thanks,
>
> Frank.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Versions of Tomcat Causing Problem with tags?

Posted by Frank Burns <fr...@the-hub.demon.co.uk>.
I am using Struts version 1.2.4 and running identical code on two different 
platforms:

1) Tomcat: v2.0.28 on XP
2) Tomcat v2.0.19 on linux.

The code on the v2.0.28 runs perfectly. However, on the v2.0.19, the 
<nested:...> tags are ignored.

Any suggestions as to what might be the source of this problem?

I am finding this VERY frustrating :-(

Thanks,

Frank.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Want to reject all-whitespace text input.

Posted by Frank Burns <fr...@the-hub.demon.co.uk>.
Where "empty" includes fields that may be full of whitespace characters. 
That explains the "strange rule" I was asking about in my original question.

----- Original Message ----- 
From: "Joe Germuska" <Jo...@Germuska.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Sunday, November 21, 2004 6:45 PM
Subject: Re: Want to reject all-whitespace text input.


> At 1:33 PM -0500 11/21/04, Erik Weber wrote:
>>I think what you want is to leave out the "required" validator, but
>>to use the "minlength" validator with a value of 1. That should
>>allow a blank, but not a String shorter than 1, and whitespace
>>should be left out in the measurement. (I'm not positive as I don't
>>have the source).
>
> I think Erik's right.  In any case, you won't get the mask validator
> to do it, since it only checks non-empty fields:
> -------
> from o.a.s.validator.FieldChecks:
>
>     public static boolean validateMask(Object bean,
>                                        ValidatorAction va, Field field,
>                                        ActionMessages errors,
>                                        HttpServletRequest request) {
>
>         String mask = field.getVarValue("mask");
>         String value = null;
>         if (isString(bean)) {
>             value = (String) bean;
>         } else {
>             value = ValidatorUtils.getValueAsString(bean, 
> field.getProperty());
>         }
>
>         try {
>             if (!GenericValidator.isBlankOrNull(value)
>                 && !GenericValidator.matchRegexp(value, mask)) {
>
>                 errors.add(
>                     field.getKey(),
>                     Resources.getActionMessage(request, va, field));
>
>                 return false;
>             } else {
>                 return true;
>             }
>         } catch (Exception e) {
>             log.error(e.getMessage(), e);
>         }
>         return true;
>     }
> -------
>
>
> --
> Joe Germuska
> Joe@Germuska.com
> http://blog.germuska.com
> "Narrow minds are weapons made for mass destruction"  -The Ex 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Want to reject all-whitespace text input.

Posted by Joe Germuska <Jo...@Germuska.com>.
At 1:33 PM -0500 11/21/04, Erik Weber wrote:
>I think what you want is to leave out the "required" validator, but 
>to use the "minlength" validator with a value of 1. That should 
>allow a blank, but not a String shorter than 1, and whitespace 
>should be left out in the measurement. (I'm not positive as I don't 
>have the source).

I think Erik's right.  In any case, you won't get the mask validator 
to do it, since it only checks non-empty fields:
-------
from o.a.s.validator.FieldChecks:

     public static boolean validateMask(Object bean,
                                        ValidatorAction va, Field field,
                                        ActionMessages errors,
                                        HttpServletRequest request) {

         String mask = field.getVarValue("mask");
         String value = null;
         if (isString(bean)) {
             value = (String) bean;
         } else {
             value = ValidatorUtils.getValueAsString(bean, field.getProperty());
         }

         try {
             if (!GenericValidator.isBlankOrNull(value)
                 && !GenericValidator.matchRegexp(value, mask)) {

                 errors.add(
                     field.getKey(),
                     Resources.getActionMessage(request, va, field));

                 return false;
             } else {
                 return true;
             }
         } catch (Exception e) {
             log.error(e.getMessage(), e);
         }
         return true;
     }
-------


--
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com
"Narrow minds are weapons made for mass destruction"  -The Ex

Re: Want to reject all-whitespace text input.

Posted by Erik Weber <er...@mindspring.com>.
I think what you want is to leave out the "required" validator, but to 
use the "minlength" validator with a value of 1. That should allow a 
blank, but not a String shorter than 1, and whitespace should be left 
out in the measurement. (I'm not positive as I don't have the source).

Erik



Frank Burns wrote:

> But I want to be able to accept an "empty" value and just reject 
> whitespace. That is, I don't want whitespace to be accepted as a vaid 
> value -- it should be either empty or contain a valid 
> (non-all-whitespace) value.
>
>
> ----- Original Message ----- From: "Joe Germuska" <Jo...@Germuska.com>
> To: "Frank Burns" <fr...@the-hub.demon.co.uk>; "Struts Users 
> Mailing List" <us...@struts.apache.org>
> Sent: Sunday, November 21, 2004 2:20 PM
> Subject: Re: Want to reject all-whitespace text input.
>
>
>> The "required" validator should do what you need.  It requires that 
>> the value be non-null and have at length > 0 after String.trim() is 
>> called.
>>
>> Joe
>>
>> At 1:22 PM +0000 11/21/04, Frank Burns wrote:
>>
>>> Hi,
>>>
>>> I am trying to write a regular expression for a mask, for use in the 
>>> validation.xml file, that will reject input text that consists of 
>>> all whitespace characters. But, no matter what pattern I try, an 
>>> all-whitespace entry is always accepted.
>>>
>>> Is there some strange rule, as part of the Validator's validation 
>>> process, that always accepts whitespace? Or is there something else 
>>> going on?
>>>
>>> Do I have to resort to accepting the all-whitespace input, detecting 
>>> it in the ActionForm's validate method and manually setting a 
>>> message in ActionErrors?
>>>
>>> Thanks,
>>>
>>> Frank.
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>>
>> -- 
>> Joe Germuska            Joe@Germuska.com  http://blog.germuska.com 
>> "Narrow minds are weapons made for mass destruction"  -The Ex 
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Want to reject all-whitespace text input.

Posted by Frank Burns <fr...@the-hub.demon.co.uk>.
But I want to be able to accept an "empty" value and just reject whitespace. 
That is, I don't want whitespace to be accepted as a vaid value -- it should 
be either empty or contain a valid (non-all-whitespace) value.


----- Original Message ----- 
From: "Joe Germuska" <Jo...@Germuska.com>
To: "Frank Burns" <fr...@the-hub.demon.co.uk>; "Struts Users Mailing 
List" <us...@struts.apache.org>
Sent: Sunday, November 21, 2004 2:20 PM
Subject: Re: Want to reject all-whitespace text input.


> The "required" validator should do what you need.  It requires that the 
> value be non-null and have at length > 0 after String.trim() is called.
>
> Joe
>
> At 1:22 PM +0000 11/21/04, Frank Burns wrote:
>>Hi,
>>
>>I am trying to write a regular expression for a mask, for use in the 
>>validation.xml file, that will reject input text that consists of all 
>>whitespace characters. But, no matter what pattern I try, an 
>>all-whitespace entry is always accepted.
>>
>>Is there some strange rule, as part of the Validator's validation process, 
>>that always accepts whitespace? Or is there something else going on?
>>
>>Do I have to resort to accepting the all-whitespace input, detecting it in 
>>the ActionForm's validate method and manually setting a message in 
>>ActionErrors?
>>
>>Thanks,
>>
>>Frank.
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>For additional commands, e-mail: user-help@struts.apache.org
>
>
> -- 
> Joe Germuska            Joe@Germuska.com  http://blog.germuska.com 
> "Narrow minds are weapons made for mass destruction"  -The Ex 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Want to reject all-whitespace text input.

Posted by Joe Germuska <Jo...@Germuska.com>.
The "required" validator should do what you need.  It requires that 
the value be non-null and have at length > 0 after String.trim() is 
called.

Joe

At 1:22 PM +0000 11/21/04, Frank Burns wrote:
>Hi,
>
>I am trying to write a regular expression for a mask, for use in the 
>validation.xml file, that will reject input text that consists of 
>all whitespace characters. But, no matter what pattern I try, an 
>all-whitespace entry is always accepted.
>
>Is there some strange rule, as part of the Validator's validation 
>process, that always accepts whitespace? Or is there something else 
>going on?
>
>Do I have to resort to accepting the all-whitespace input, detecting 
>it in the ActionForm's validate method and manually setting a 
>message in ActionErrors?
>
>Thanks,
>
>Frank.
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"Narrow minds are weapons made for mass destruction"  -The Ex

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Want to reject all-whitespace text input.

Posted by Frank Burns <fr...@the-hub.demon.co.uk>.
Hi,

I am trying to write a regular expression for a mask, for use in the 
validation.xml file, that will reject input text that consists of all 
whitespace characters. But, no matter what pattern I try, an all-whitespace 
entry is always accepted.

Is there some strange rule, as part of the Validator's validation process, 
that always accepts whitespace? Or is there something else going on?

Do I have to resort to accepting the all-whitespace input, detecting it in 
the ActionForm's validate method and manually setting a message in 
ActionErrors?

Thanks,

Frank. 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How can I do this ... ?

Posted by Hubert Rabago <hr...@gmail.com>.
It sounds like the list contains the same type, several times over. 
If so, just use indexed properties.

http://struts.apache.org/faqs/indexedprops.html
http://www.developer.com/java/ejb/article.php/2233591

If I misunderstood your question, ignore my answer.  Or you can study
them anyway to know what type of support Struts has for "unknown
number of elements"-type forms.

Hubert

On Sat, 20 Nov 2004 12:40:53 -0000, Frank Burns
<fr...@the-hub.demon.co.uk> wrote:
> Hi,
> 
> Although I have been using Struts for a while now, I have this new requirement and I don't know an obvious way to implement it. Can anyone please tell me how I can do this?
> 
> BACKGROUND: I want to display a list of existing items of a certain type and allow users to edit these and save them. I don't know how long the list is -- it may be one or 100 or any number of items long.
> 
> QUESTION: So, how do I write an ActionForm to accept an UNKNOWN number of items? And how do I "dynamically" write the required number of <html:text> tags (appropriately labelled) to be able to accept the values returned from the ActionForm if validation fails?
> 
> Thanks,
> 
> Frank.
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: How can I do this ... ?

Posted by klute <so...@yahoo.com>.
Sounds like you need to implement a list-backed form. 

http://forum.java.sun.com/thread.jspa?forumID=33&messageID=1952256&threadID=435161

best,
james

--- Frank Burns <fr...@the-hub.demon.co.uk>
wrote:

> Hi,
> 
> Although I have been using Struts for a while now, I
> have this new requirement and I don't know an
> obvious way to implement it. Can anyone please tell
> me how I can do this?
> 
> BACKGROUND: I want to display a list of existing
> items of a certain type and allow users to edit
> these and save them. I don't know how long the list
> is -- it may be one or 100 or any number of items
> long.
> 
> QUESTION: So, how do I write an ActionForm to accept
> an UNKNOWN number of items? And how do I
> "dynamically" write the required number of
> <html:text> tags (appropriately labelled) to be able
> to accept the values returned from the ActionForm if
> validation fails?
> 
> Thanks,
> 
> Frank.
> 



		
__________________________________ 
Do you Yahoo!? 
Meet the all-new My Yahoo! - Try it today! 
http://my.yahoo.com 
 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org