You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by ad...@cyberspaceroad.com on 2002/06/12 15:15:30 UTC

Nested Tags question

Hi All,
I am trying to save a list created with the nested:iterate tag (from an
object array in my form bean). I've written my code by following the
SaveMonkey example from Arron Bates' KeyboardMonkey site (kudos to you,
capt'n) - but the object array doesn't get recreated on a submit!

Can I use a nested:iterate tag on an array straight out of the form
bean? That seems to be the only difference I can see between mine and
the SaveMonkey demo.

The setList(Object[] newList) isn't working. Struts or Tomcat isn't
recognising it as a normal javabean property setter I guess. Here's what
the HTML looks like:

<form name="operationForm" method="POST"
action="/apla/operationList.do">
  <input type="hidden" name="list[0].opIdString" value="31">
  <input type="text" name="list[0].packageName" value="Pack1">          


Should I keep looking for a bug that's stopping the setList() method
from being recognised as a setter method?

Thanks if you can help,
Adam

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


Re: Nested Tags question

Posted by Arron Bates <st...@keyboardmonkey.com>.
Adam,

Should say that the monkey example's not the mos simple example. It's 
more of a "what's possible" than a learners tool.

I just posted the link to the tute's and primer. The Tute's walk through 
from a plain, non-nested bean, to the initial nesting, to the lists, and 
lists within lists... I'd recommend going that way. For convenience, 
that link again...

    http://www.keyboardmonkey.com/next

A couple of people have had a stumbling start because they found the 
monkey example first and love to hack that than take the walking tour. 
I'm considering removing it from the nesting-newbie eye.

If you have any more issues or questiong, you know where we are...


Arron.


adam.hardy@cyberspaceroad.com wrote:

>Hi All,
>I am trying to save a list created with the nested:iterate tag (from an
>object array in my form bean). I've written my code by following the
>SaveMonkey example from Arron Bates' KeyboardMonkey site (kudos to you,
>capt'n) - but the object array doesn't get recreated on a submit!
>
>Can I use a nested:iterate tag on an array straight out of the form
>bean? That seems to be the only difference I can see between mine and
>the SaveMonkey demo.
>
>The setList(Object[] newList) isn't working. Struts or Tomcat isn't
>recognising it as a normal javabean property setter I guess. Here's what
>the HTML looks like:
>
><form name="operationForm" method="POST"
>action="/apla/operationList.do">
>  <input type="hidden" name="list[0].opIdString" value="31">
>  <input type="text" name="list[0].packageName" value="Pack1">          
>
>
>Should I keep looking for a bug that's stopping the setList() method
>from being recognised as a setter method?
>
>Thanks if you can help,
>Adam
>
>--
>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: Nested Tags question

Posted by Arron Bates <st...@keyboardmonkey.com>.
> As far as the problem goes concerning setting against valid indices, 
> my code does that simply enough using a check against ArrayList.size() 
> and the index from the request parameter - if the size is too small, I 
> just add new objects - 3 lines of code. This is all in a for loop, 
> which could recurse - presumably what your commons wrapper does. Guess 
> I'll find out. 



That's pretty much what it does.
Only thing is it's tackled at the collection level so that you only need 
to use the properties which return and set the collection itself. You 
have to provide one of these to the iterate tags anyways. Means you 
don't have to manage the collections yourself.

It's all of a muchness, so I'll just say it's less to be concerned with 
on a regular basis as a wrapper  :)


Arron.


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


Re: select dropdown with a nested name-attribute doesnt work in any browser - sends wrong value in request

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
How many rows do you generally iterate? More than one I presume on 
average? I mean, is it possible that you've only ever tried it with just 
one row and never with more than one row?

SATISH.T wrote:

>This is the html produced,  since I put it in the iterate tag the array
>index changes...
>Nested:define does not generate any html but I use it to hold the
>collection which 
>I set in the form for each of my combo box .
>
><select name="holdingCentreList[0].bandName" onchange="trial(1)">
><option value="Doors">Doors</option>
><option value="Zepplin">Zepplin</option>
><option value="Floyd">Floyd</option>
></select>
>
>-----Original Message-----
>From: Adam Hardy [mailto:adam.hardy@cyberspaceroad.com] 
>Sent: Friday, June 14, 2002 6:10 PM
>To: Struts Users Mailing List
>Subject: Re: select dropdown with a nested name-attribute doesnt work in
>any browser - sends wrong value in request
>
>Oh! It's a mystery to me then why my HTML doesn't work. Can you send the
>
>HTML that these tags produce? Does that nested:define produce html? What
>
>role does it play?
>
>thanks
>Adam
>
>SATISH.T wrote:
>
>  
>
>>Hi I have tried out nested:select in both IE and netscape and it works
>>fine. The property bandList is the one I set in my nested beans which
>>    
>>
>is
>  
>
>>a collection (Arraylist ) of label Value beans(name-value pairs).
>>This is the syntax I use and the values are returned properly.
>><nested:define id="Y" property="bandList"/>
>>	 <nested:select property="bandName"
>>onchange="<%=\"trial(\"+counter+\")\"%>" >
>>	<html:options collection="Y" property="label"
>>labelProperty="value"/>
>></nested:select>  	
>>
>>
>>-----Original Message-----
>>From: adam.hardy@cyberspaceroad.com
>>[mailto:adam.hardy@cyberspaceroad.com] 
>>Sent: Friday, June 14, 2002 2:21 PM
>>To: Struts Users Mailing List
>>Subject: select dropdown with a nested name-attribute doesnt work in
>>    
>>
>any
>  
>
>>browser - sends wrong value in request
>>
>>Neither Mozilla nor IE are handling my HTML produced from nested tags.
>>They ignore any selection I make in a select dropdown when I submit.
>>    
>>
>The
>  
>
>>incoming parameters at the server show that the original value is
>>    
>>
>always
>  
>
>>sent. 
>>
>>My HTML:
>>
>><select name="operationList[0].locationIdString">
>><option value="0" selected="selected">-- please select --</option>
>><option value="1">Strange Location</option>
>><option value="2">Up a tree</option>
>><option value="3">Kebabhouse</option>
>></select>
>>
>>In my debug logging, I see all the other parameters with correct
>>    
>>
>values,
>  
>
>>but I get operation[0].locationIdString=0 no matter what I select.
>>
>>Is anybody successfully using nested dropdowns / select boxes? Why does
>>this affect both browsers? Am I going mad?
>>
>>Adam
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>> 
>>
>>-----------------------------------------------------------------------
>>    
>>
>-
>  
>
>>**************************Disclaimer***********************************
>>    
>>
>*
>  
>
>>Information contained in this E-MAIL being proprietary to Wipro Limited
>>    
>>
>is 
>  
>
>>'privileged' and 'confidential' and intended for use only by the
>>    
>>
>individual
>  
>
>>or entity to which it is addressed. You are notified that any use,
>>    
>>
>copying 
>  
>
>>or dissemination of the information contained in the E-MAIL in any
>>    
>>
>manner 
>  
>
>>whatsoever is strictly prohibited.
>>
>>***********************************************************************
>>    
>>
>****
>  
>
>> 
>>
>>-----------------------------------------------------------------------
>>    
>>
>-
>  
>
>>--
>>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>
>
>  
>
>------------------------------------------------------------------------
>
>**************************Disclaimer************************************
>
>Information contained in this E-MAIL being proprietary to Wipro Limited is 
>'privileged' and 'confidential' and intended for use only by the individual
> or entity to which it is addressed. You are notified that any use, copying 
>or dissemination of the information contained in the E-MAIL in any manner 
>whatsoever is strictly prohibited.
>
>***************************************************************************
>
>  
>
>------------------------------------------------------------------------
>
>--
>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: select dropdown with a nested name-attribute doesnt work in any browser - sends wrong value in request

Posted by "SATISH.T" <sa...@wipro.com>.
This is the html produced,  since I put it in the iterate tag the array
index changes...
Nested:define does not generate any html but I use it to hold the
collection which 
I set in the form for each of my combo box .

<select name="holdingCentreList[0].bandName" onchange="trial(1)">
<option value="Doors">Doors</option>
<option value="Zepplin">Zepplin</option>
<option value="Floyd">Floyd</option>
</select>

-----Original Message-----
From: Adam Hardy [mailto:adam.hardy@cyberspaceroad.com] 
Sent: Friday, June 14, 2002 6:10 PM
To: Struts Users Mailing List
Subject: Re: select dropdown with a nested name-attribute doesnt work in
any browser - sends wrong value in request

Oh! It's a mystery to me then why my HTML doesn't work. Can you send the

HTML that these tags produce? Does that nested:define produce html? What

role does it play?

thanks
Adam

SATISH.T wrote:

>Hi I have tried out nested:select in both IE and netscape and it works
>fine. The property bandList is the one I set in my nested beans which
is
>a collection (Arraylist ) of label Value beans(name-value pairs).
>This is the syntax I use and the values are returned properly.
><nested:define id="Y" property="bandList"/>
>	 <nested:select property="bandName"
>onchange="<%=\"trial(\"+counter+\")\"%>" >
>	<html:options collection="Y" property="label"
>labelProperty="value"/>
> </nested:select>  	
>
>
>-----Original Message-----
>From: adam.hardy@cyberspaceroad.com
>[mailto:adam.hardy@cyberspaceroad.com] 
>Sent: Friday, June 14, 2002 2:21 PM
>To: Struts Users Mailing List
>Subject: select dropdown with a nested name-attribute doesnt work in
any
>browser - sends wrong value in request
>
>Neither Mozilla nor IE are handling my HTML produced from nested tags.
>They ignore any selection I make in a select dropdown when I submit.
The
>incoming parameters at the server show that the original value is
always
>sent. 
>
>My HTML:
>
><select name="operationList[0].locationIdString">
><option value="0" selected="selected">-- please select --</option>
><option value="1">Strange Location</option>
><option value="2">Up a tree</option>
><option value="3">Kebabhouse</option>
></select>
>
>In my debug logging, I see all the other parameters with correct
values,
>but I get operation[0].locationIdString=0 no matter what I select.
>
>Is anybody successfully using nested dropdowns / select boxes? Why does
>this affect both browsers? Am I going mad?
>
>Adam
>
>--
>To unsubscribe, e-mail:
><ma...@jakarta.apache.org>
>For additional commands, e-mail:
><ma...@jakarta.apache.org>
>
>  
>
>-----------------------------------------------------------------------
-
>
>**************************Disclaimer***********************************
*
>
>Information contained in this E-MAIL being proprietary to Wipro Limited
is 
>'privileged' and 'confidential' and intended for use only by the
individual
> or entity to which it is addressed. You are notified that any use,
copying 
>or dissemination of the information contained in the E-MAIL in any
manner 
>whatsoever is strictly prohibited.
>
>***********************************************************************
****
>
>  
>
>-----------------------------------------------------------------------
-
>
>--
>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: select dropdown with a nested name-attribute doesnt work in any browser - sends wrong value in request

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
Oh! It's a mystery to me then why my HTML doesn't work. Can you send the 
HTML that these tags produce? Does that nested:define produce html? What 
role does it play?

thanks
Adam

SATISH.T wrote:

>Hi I have tried out nested:select in both IE and netscape and it works
>fine. The property bandList is the one I set in my nested beans which is
>a collection (Arraylist ) of label Value beans(name-value pairs).
>This is the syntax I use and the values are returned properly.
><nested:define id="Y" property="bandList"/>
>	 <nested:select property="bandName"
>onchange="<%=\"trial(\"+counter+\")\"%>" >
>	<html:options collection="Y" property="label"
>labelProperty="value"/>
> </nested:select>  	
>
>
>-----Original Message-----
>From: adam.hardy@cyberspaceroad.com
>[mailto:adam.hardy@cyberspaceroad.com] 
>Sent: Friday, June 14, 2002 2:21 PM
>To: Struts Users Mailing List
>Subject: select dropdown with a nested name-attribute doesnt work in any
>browser - sends wrong value in request
>
>Neither Mozilla nor IE are handling my HTML produced from nested tags.
>They ignore any selection I make in a select dropdown when I submit. The
>incoming parameters at the server show that the original value is always
>sent. 
>
>My HTML:
>
><select name="operationList[0].locationIdString">
><option value="0" selected="selected">-- please select --</option>
><option value="1">Strange Location</option>
><option value="2">Up a tree</option>
><option value="3">Kebabhouse</option>
></select>
>
>In my debug logging, I see all the other parameters with correct values,
>but I get operation[0].locationIdString=0 no matter what I select.
>
>Is anybody successfully using nested dropdowns / select boxes? Why does
>this affect both browsers? Am I going mad?
>
>Adam
>
>--
>To unsubscribe, e-mail:
><ma...@jakarta.apache.org>
>For additional commands, e-mail:
><ma...@jakarta.apache.org>
>
>  
>
>------------------------------------------------------------------------
>
>**************************Disclaimer************************************
>
>Information contained in this E-MAIL being proprietary to Wipro Limited is 
>'privileged' and 'confidential' and intended for use only by the individual
> or entity to which it is addressed. You are notified that any use, copying 
>or dissemination of the information contained in the E-MAIL in any manner 
>whatsoever is strictly prohibited.
>
>***************************************************************************
>
>  
>
>------------------------------------------------------------------------
>
>--
>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>


help needed - default selection in dynamic select boxes.

Posted by Yaman Kumar <ya...@nous.soft.net>.
Hi,
I am using struts v1.0.2 and heard this does not support generation of
dynamic html controls through struts tags(????).

I have a collection of ComboBoxBeans with name-value pair in a Vector to
show
html options  and would like to use it with 2nd collection .
I have a problem in rendering default selection in select boxes that are
rendered by 2nd collection.
( In mvc lt looks like this ).

<%for(int k=0;(vectStudents!=null && k<vectStudents.size());k++){
   Student student = (student)vectStudents.elementAt(k);
   String type = student.getType();
%>

<select name="studentType" >

<% LinkedList studentTypes = myBean.getAllTypes();
   String strSelected = "";
   for(int I=0;i<studentTypes.size();i++){
       ComboBoxBean objCombBean = (ComboBoxBean)studentTypes.get(i);
       String code = objCombBean.getCode();
       String description = objCombBean.getDescription();
       strSelected = description.trim().equals(type .trim())?"selected":"";
%>
     <option <%= strSelected %> value="<%= code %>"> <%= description %>
</option>

<%	 }%>
</select>
<%}%>


Can I get the above code in struts implemented ? is it possible with 1.0.2?"
Is there any nested tag information available .
TIA
rayaku

-----Original Message-----
From: SATISH.T [mailto:satish.terala@wipro.com]
Sent: Friday, 14 June 2002 2:36 PM
To: 'Struts Users Mailing List'
Subject: RE: select dropdown with a nested name-attribute doesnt work in
any browser - sends wrong value in request


Hi I have tried out nested:select in both IE and netscape and it works
fine. The property bandList is the one I set in my nested beans which is
a collection (Arraylist ) of label Value beans(name-value pairs).
This is the syntax I use and the values are returned properly.
<nested:define id="Y" property="bandList"/>
	 <nested:select property="bandName"
onchange="<%=\"trial(\"+counter+\")\"%>" >
	<html:options collection="Y" property="label"
labelProperty="value"/>
 </nested:select>


-----Original Message-----
From: adam.hardy@cyberspaceroad.com
[mailto:adam.hardy@cyberspaceroad.com]
Sent: Friday, June 14, 2002 2:21 PM
To: Struts Users Mailing List
Subject: select dropdown with a nested name-attribute doesnt work in any
browser - sends wrong value in request

Neither Mozilla nor IE are handling my HTML produced from nested tags.
They ignore any selection I make in a select dropdown when I submit. The
incoming parameters at the server show that the original value is always
sent.

My HTML:

<select name="operationList[0].locationIdString">
<option value="0" selected="selected">-- please select --</option>
<option value="1">Strange Location</option>
<option value="2">Up a tree</option>
<option value="3">Kebabhouse</option>
</select>

In my debug logging, I see all the other parameters with correct values,
but I get operation[0].locationIdString=0 no matter what I select.

Is anybody successfully using nested dropdowns / select boxes? Why does
this affect both browsers? Am I going mad?

Adam

--
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: select dropdown with a nested name-attribute doesnt work in any browser - sends wrong value in request

Posted by "SATISH.T" <sa...@wipro.com>.
Hi I have tried out nested:select in both IE and netscape and it works
fine. The property bandList is the one I set in my nested beans which is
a collection (Arraylist ) of label Value beans(name-value pairs).
This is the syntax I use and the values are returned properly.
<nested:define id="Y" property="bandList"/>
	 <nested:select property="bandName"
onchange="<%=\"trial(\"+counter+\")\"%>" >
	<html:options collection="Y" property="label"
labelProperty="value"/>
 </nested:select>  	


-----Original Message-----
From: adam.hardy@cyberspaceroad.com
[mailto:adam.hardy@cyberspaceroad.com] 
Sent: Friday, June 14, 2002 2:21 PM
To: Struts Users Mailing List
Subject: select dropdown with a nested name-attribute doesnt work in any
browser - sends wrong value in request

Neither Mozilla nor IE are handling my HTML produced from nested tags.
They ignore any selection I make in a select dropdown when I submit. The
incoming parameters at the server show that the original value is always
sent. 

My HTML:

<select name="operationList[0].locationIdString">
<option value="0" selected="selected">-- please select --</option>
<option value="1">Strange Location</option>
<option value="2">Up a tree</option>
<option value="3">Kebabhouse</option>
</select>

In my debug logging, I see all the other parameters with correct values,
but I get operation[0].locationIdString=0 no matter what I select.

Is anybody successfully using nested dropdowns / select boxes? Why does
this affect both browsers? Am I going mad?

Adam

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


select dropdown with a nested name-attribute doesnt work in any browser - sends wrong value in request

Posted by ad...@cyberspaceroad.com.
Neither Mozilla nor IE are handling my HTML produced from nested tags.
They ignore any selection I make in a select dropdown when I submit. The
incoming parameters at the server show that the original value is always
sent. 

My HTML:

<select name="operationList[0].locationIdString">
<option value="0" selected="selected">-- please select --</option>
<option value="1">Strange Location</option>
<option value="2">Up a tree</option>
<option value="3">Kebabhouse</option>
</select>

In my debug logging, I see all the other parameters with correct values,
but I get operation[0].locationIdString=0 no matter what I select.

Is anybody successfully using nested dropdowns / select boxes? Why does
this affect both browsers? Am I going mad?

Adam

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


Re: Nested Tags question

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
Hi there,
I'll take a look at it this weekend. I don't get your reference to no 
session objects.

As far as the problem goes concerning setting against valid indices, my 
code does that simply enough using a check against ArrayList.size() and 
the index from the request parameter - if the size is too small, I just 
add new objects - 3 lines of code. This is all in a for loop, which 
could recurse - presumably what your commons wrapper does. Guess I'll 
find out.

All the best
Adam

Arron Bates wrote:

> Adam,
>
> Back to the old "want lists, but no session objects" issue. It's a 
> common problem these days. It's hard to get the list model working 
> nicely without "knowing" how big the list is going to be so that 
> objects can be set against valid indexes.
>
> The post you speek of in the archives is that I've made a collections 
> wrapps in the commons project which will wrap collections so that they 
> can expand by definition when the request comes in with indexed or 
> mapped properties.
>
> I'm cutting a short tutorial on it ("how to make funky complex form 
> models leaving the session object in the closet"), should be finished 
> in the next few days. It should help a lot of people. Most people end 
> up with indexed lists, but it's hard to get them working properly on 
> the back end. It's not just a nested tags thing.
>
> If you don't mind wading through code and having a go at the 
> collections wrapper with nothing but javadoc (good javadoc though :)...
>
> http://cvs.apache.org/viewcvs/jakarta-commons/collections/src/java/org/apache/commons/collections/LazyCollections.java 
>
>
>
> Arron.
>
>
> Adam Hardy wrote:
>
>> Hi Down Under,
>>
>> thanks for the reply. I figured that the form properties setting 
>> thing must be struts, after checking out the JSP spec. JSP does do a 
>> certain amount of it though, since you can specify a tag in your jsp 
>> and say parameters="*" - and JSP will match any parameters in the 
>> request to methods on the tag's bean.
>>
>> Anyway sorry for sounding like such a dumbass but I've been through 
>> your tutorials. For the display, I've got the nested tags sussed - 
>> it's for the save on submit that I'm having problems. It's one of 
>> those aggravating problems that I can't pin down so it's difficult to 
>> ask the right questions.
>>
>> I've actually hacked out some code to stuff the request parameters 
>> into the bean structure by hand in the form's validate method. 
>> Obviously I'd like to do it automatically but I had to get the app 
>> working. To try to sort out what I've done wrong, I'll strip it back 
>> to the simplest bare bones and take it from there.
>>
>> What I can't work out from playing with your SavingMonkey demo is how 
>> struts gets the request parameters into beans inside each other 
>> inside the formbean. Is it necessary to instantiate the right amount 
>> of empty beans first? I see SavingMonkey instantiates everything on 
>> construction.
>>
>> When saving request parameters to the beans in the formbean, does 
>> struts call the beans' getter methods to get the ArrayLists and 
>> beans? I can't see how else it would get access the setter methods on 
>> the deeper nested beans.
>>
>> Thanks for your help. I did see a message in the archives here but I 
>> can't find it again, where you were talking about changes awaiting 
>> acceptance in CVS - is that just stuff that is now incorporated into 
>> struts 1.1? I'm using 1.0.2
>>
>> All the best,
>> Adam
>
>
>
>
>
> -- 
> 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: Nested Tags question

Posted by Arron Bates <st...@keyboardmonkey.com>.
Adam,

Back to the old "want lists, but no session objects" issue. It's a 
common problem these days. It's hard to get the list model working 
nicely without "knowing" how big the list is going to be so that objects 
can be set against valid indexes.

The post you speek of in the archives is that I've made a collections 
wrapps in the commons project which will wrap collections so that they 
can expand by definition when the request comes in with indexed or 
mapped properties.

I'm cutting a short tutorial on it ("how to make funky complex form 
models leaving the session object in the closet"), should be finished in 
the next few days. It should help a lot of people. Most people end up 
with indexed lists, but it's hard to get them working properly on the 
back end. It's not just a nested tags thing.

If you don't mind wading through code and having a go at the collections 
wrapper with nothing but javadoc (good javadoc though :)...

http://cvs.apache.org/viewcvs/jakarta-commons/collections/src/java/org/apache/commons/collections/LazyCollections.java


Arron.


Adam Hardy wrote:

> Hi Down Under,
>
> thanks for the reply. I figured that the form properties setting thing 
> must be struts, after checking out the JSP spec. JSP does do a certain 
> amount of it though, since you can specify a tag in your jsp and say 
> parameters="*" - and JSP will match any parameters in the request to 
> methods on the tag's bean.
>
> Anyway sorry for sounding like such a dumbass but I've been through 
> your tutorials. For the display, I've got the nested tags sussed - 
> it's for the save on submit that I'm having problems. It's one of 
> those aggravating problems that I can't pin down so it's difficult to 
> ask the right questions.
>
> I've actually hacked out some code to stuff the request parameters 
> into the bean structure by hand in the form's validate method. 
> Obviously I'd like to do it automatically but I had to get the app 
> working. To try to sort out what I've done wrong, I'll strip it back 
> to the simplest bare bones and take it from there.
>
> What I can't work out from playing with your SavingMonkey demo is how 
> struts gets the request parameters into beans inside each other inside 
> the formbean. Is it necessary to instantiate the right amount of empty 
> beans first? I see SavingMonkey instantiates everything on construction.
>
> When saving request parameters to the beans in the formbean, does 
> struts call the beans' getter methods to get the ArrayLists and beans? 
> I can't see how else it would get access the setter methods on the 
> deeper nested beans.
>
> Thanks for your help. I did see a message in the archives here but I 
> can't find it again, where you were talking about changes awaiting 
> acceptance in CVS - is that just stuff that is now incorporated into 
> struts 1.1? I'm using 1.0.2
>
> All the best,
> Adam




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


Re: Nested Tags question

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
Hi Down Under,

thanks for the reply. I figured that the form properties setting thing 
must be struts, after checking out the JSP spec. JSP does do a certain 
amount of it though, since you can specify a tag in your jsp and say 
parameters="*" - and JSP will match any parameters in the request to 
methods on the tag's bean.

Anyway sorry for sounding like such a dumbass but I've been through your 
tutorials. For the display, I've got the nested tags sussed - it's for 
the save on submit that I'm having problems. It's one of those 
aggravating problems that I can't pin down so it's difficult to ask the 
right questions.

I've actually hacked out some code to stuff the request parameters into 
the bean structure by hand in the form's validate method. Obviously I'd 
like to do it automatically but I had to get the app working. To try to 
sort out what I've done wrong, I'll strip it back to the simplest bare 
bones and take it from there.

What I can't work out from playing with your SavingMonkey demo is how 
struts gets the request parameters into beans inside each other inside 
the formbean. Is it necessary to instantiate the right amount of empty 
beans first? I see SavingMonkey instantiates everything on construction.

When saving request parameters to the beans in the formbean, does struts 
call the beans' getter methods to get the ArrayLists and beans? I can't 
see how else it would get access the setter methods on the deeper nested 
beans.

Thanks for your help. I did see a message in the archives here but I 
can't find it again, where you were talking about changes awaiting 
acceptance in CVS - is that just stuff that is now incorporated into 
struts 1.1? I'm using 1.0.2

All the best,
Adam

Arron Bates wrote:

>>
>>
>> I know JSP will automatically save parameters to a javabean with the
>> correctly named getters and setters, but there's obviously a gap in my
>> knowledge because all my attempts to recreate the situation above have
>> failed.
>
>
> Setting form properties against beans is a Struts thing, not a JSP 
> thing. The property thing is a Bean thin and can be looked up in the 
> JavaBean spec.
>
> The example you quote...
>
>    "monkeyTeamAlpha.monkeyWorkers[0].salary"
>
>        ...is a nested property. An invention implemented within Struts 
> (Craig?). What it basically is, is a string of calls rather than the 
> single property method. Here, it will get a hold of the form bean, get 
> a hold of the bean returned from the "monkeyTeamAlpha"property. On 
> this bean, it will invoke the indexed property "monkeyWorkers[0]" 
> which will pluck a bean from a collection or index provided, from this 
> last bean it will will get a hold of its "salary" property, and set 
> the value.
>
> All this boils down to, is that you can compose objects a little 
> cleaner, rather than have truly enormous beans for everything. Having 
> the indexed properties allows for lists and whatever else.
>
> The ability for nesting beans has been in Struts for a long time. The 
> nested tags just make it much easier.
>
> There's a primer and tutorial for nested beans here...
>
>    http://www.keyboardmonkey.com/next
>
>        ...it should take you over creating and using such a construct.
>
> Hope this gets you on th path you're after.
>
>
> Arron.
>
>
> -- 
> 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: Re: Nested Tags question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 13 Jun 2002 adam.hardy@cyberspaceroad.com wrote:

> Date: Thu, 13 Jun 2002 11:43:59 +0200
> From: adam.hardy@cyberspaceroad.com
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Re: Nested Tags question
>
> So Craig,
> does the process work at submit time (when the request parameters are
> being put into the nested beans) via calls to the getter methods to get
> the beans on which the parameters have to be set?
>
> I can't see how else it would work.
>

It depends on what context you are using the expressions in.  For example:

  <!-- Assume the form bean name is "customerForm" -->
  <html:form action="/editCustomer">
    ...
    <html:text property="mailingAddress.city"/>
    ...
  </html:form>

will, in effect, do a call to:

  customerForm.getMailingAddress().getCity()

when the page is displayed, and a call to:

  customerForm.getMailingAddress().setCity()

when the request parameters are being copied in to the form bean.

>
> Adam
>

Craig


>
>
> "Craig R. McClanahan" <cr...@apache.org> schrieb am 13.06.2002,
> 08:22:43:
> >
> >
> > On Thu, 13 Jun 2002, Arron Bates wrote:
> >
> > > Date: Thu, 13 Jun 2002 14:14:13 +1000
> > > From: Arron Bates
> > > Reply-To: Struts Users Mailing List
> > > To: Struts Users Mailing List
> > > Subject: Re: Nested Tags question
> > >
> > > >
> > > >
> > > >I know JSP will automatically save parameters to a javabean with the
> > > >correctly named getters and setters, but there's obviously a gap in my
> > > >knowledge because all my attempts to recreate the situation above have
> > > >failed.
> > > >
> > >
> > > Setting form properties against beans is a Struts thing, not a JSP
> > > thing. The property thing is a Bean thin and can be looked up in the
> > > JavaBean spec.
> > >
> > > The example you quote...
> > >
> > >     "monkeyTeamAlpha.monkeyWorkers[0].salary"
> > >
> > >         ...is a nested property. An invention implemented within Struts
> > > (Craig?).
> >
> > Yep, although in Struts 1.1 it is really a "commons-beanutils" thing
> > because we abstracted out this generally useful code into a separate
> > package.
> >
> > > What it basically is, is a string of calls rather than the
> > > single property method. Here, it will get a hold of the form bean, get a
> > > hold of the bean returned from the "monkeyTeamAlpha"property. On this
> > > bean, it will invoke the indexed property "monkeyWorkers[0]" which will
> > > pluck a bean from a collection or index provided, from this last bean it
> > > will will get a hold of its "salary" property, and set the value.
> > >
> >
> > At each stage, you also get the benefit of some intelligence that is built
> > in to the underlying PropertyUtils class.  For example, the JavaBeans spec
> > defines two ways to define an indexed property -- you can use getter and
> > setter methods that take a value and a subscript, or you can use getter
> > and setter methods that return the entire array.  PropertyUtils makes the
> > expression listed above work for either (or even for a property whose
> > value is a java.util.List, which is an extension to the JavaBeans spec).
> >
> > > All this boils down to, is that you can compose objects a little
> > > cleaner, rather than have truly enormous beans for everything. Having
> > > the indexed properties allows for lists and whatever else.
> > >
> > > The ability for nesting beans has been in Struts for a long time. The
> > > nested tags just make it much easier.
> > >
> > > There's a primer and tutorial for nested beans here...
> > >
> > >     http://www.keyboardmonkey.com/next
> > >
> > >         ...it should take you over creating and using such a construct.
> > >
> > > Hope this gets you on th path you're after.
> >
> > Another area of useful learning for the future is the JSP Standard Tag
> > Library (JSTL).  Although the expression language syntax supported by JSTL
> > is different from the one in Struts, it is well worth learning about --
> > this expression language will be supported anywhere in a JSP page in JSP
> > 1.3, and (in the mean time) we will likely adapt Struts tags to be able to
> > use it as well.
> >
> > >
> > >
> > > Arron.
> > >
> >
> > Craig
> >
> >
> > --
> > To unsubscribe, e-mail:
> > For additional commands, e-mail:
>
> --
> 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: Re: Nested Tags question

Posted by ad...@cyberspaceroad.com.
So Craig, 
does the process work at submit time (when the request parameters are
being put into the nested beans) via calls to the getter methods to get
the beans on which the parameters have to be set? 

I can't see how else it would work.


Adam



"Craig R. McClanahan" <cr...@apache.org> schrieb am 13.06.2002,
08:22:43:
> 
> 
> On Thu, 13 Jun 2002, Arron Bates wrote:
> 
> > Date: Thu, 13 Jun 2002 14:14:13 +1000
> > From: Arron Bates 
> > Reply-To: Struts Users Mailing List 
> > To: Struts Users Mailing List 
> > Subject: Re: Nested Tags question
> >
> > >
> > >
> > >I know JSP will automatically save parameters to a javabean with the
> > >correctly named getters and setters, but there's obviously a gap in my
> > >knowledge because all my attempts to recreate the situation above have
> > >failed.
> > >
> >
> > Setting form properties against beans is a Struts thing, not a JSP
> > thing. The property thing is a Bean thin and can be looked up in the
> > JavaBean spec.
> >
> > The example you quote...
> >
> >     "monkeyTeamAlpha.monkeyWorkers[0].salary"
> >
> >         ...is a nested property. An invention implemented within Struts
> > (Craig?).
> 
> Yep, although in Struts 1.1 it is really a "commons-beanutils" thing
> because we abstracted out this generally useful code into a separate
> package.
> 
> > What it basically is, is a string of calls rather than the
> > single property method. Here, it will get a hold of the form bean, get a
> > hold of the bean returned from the "monkeyTeamAlpha"property. On this
> > bean, it will invoke the indexed property "monkeyWorkers[0]" which will
> > pluck a bean from a collection or index provided, from this last bean it
> > will will get a hold of its "salary" property, and set the value.
> >
> 
> At each stage, you also get the benefit of some intelligence that is built
> in to the underlying PropertyUtils class.  For example, the JavaBeans spec
> defines two ways to define an indexed property -- you can use getter and
> setter methods that take a value and a subscript, or you can use getter
> and setter methods that return the entire array.  PropertyUtils makes the
> expression listed above work for either (or even for a property whose
> value is a java.util.List, which is an extension to the JavaBeans spec).
> 
> > All this boils down to, is that you can compose objects a little
> > cleaner, rather than have truly enormous beans for everything. Having
> > the indexed properties allows for lists and whatever else.
> >
> > The ability for nesting beans has been in Struts for a long time. The
> > nested tags just make it much easier.
> >
> > There's a primer and tutorial for nested beans here...
> >
> >     http://www.keyboardmonkey.com/next
> >
> >         ...it should take you over creating and using such a construct.
> >
> > Hope this gets you on th path you're after.
> 
> Another area of useful learning for the future is the JSP Standard Tag
> Library (JSTL).  Although the expression language syntax supported by JSTL
> is different from the one in Struts, it is well worth learning about --
> this expression language will be supported anywhere in a JSP page in JSP
> 1.3, and (in the mean time) we will likely adapt Struts tags to be able to
> use it as well.
> 
> >
> >
> > Arron.
> >
> 
> Craig
> 
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail:

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


Re: Nested Tags question

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Thu, 13 Jun 2002, Arron Bates wrote:

> Date: Thu, 13 Jun 2002 14:14:13 +1000
> From: Arron Bates <st...@keyboardmonkey.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Re: Nested Tags question
>
> >
> >
> >I know JSP will automatically save parameters to a javabean with the
> >correctly named getters and setters, but there's obviously a gap in my
> >knowledge because all my attempts to recreate the situation above have
> >failed.
> >
>
> Setting form properties against beans is a Struts thing, not a JSP
> thing. The property thing is a Bean thin and can be looked up in the
> JavaBean spec.
>
> The example you quote...
>
>     "monkeyTeamAlpha.monkeyWorkers[0].salary"
>
>         ...is a nested property. An invention implemented within Struts
> (Craig?).

Yep, although in Struts 1.1 it is really a "commons-beanutils" thing
because we abstracted out this generally useful code into a separate
package.

> What it basically is, is a string of calls rather than the
> single property method. Here, it will get a hold of the form bean, get a
> hold of the bean returned from the "monkeyTeamAlpha"property. On this
> bean, it will invoke the indexed property "monkeyWorkers[0]" which will
> pluck a bean from a collection or index provided, from this last bean it
> will will get a hold of its "salary" property, and set the value.
>

At each stage, you also get the benefit of some intelligence that is built
in to the underlying PropertyUtils class.  For example, the JavaBeans spec
defines two ways to define an indexed property -- you can use getter and
setter methods that take a value and a subscript, or you can use getter
and setter methods that return the entire array.  PropertyUtils makes the
expression listed above work for either (or even for a property whose
value is a java.util.List, which is an extension to the JavaBeans spec).

> All this boils down to, is that you can compose objects a little
> cleaner, rather than have truly enormous beans for everything. Having
> the indexed properties allows for lists and whatever else.
>
> The ability for nesting beans has been in Struts for a long time. The
> nested tags just make it much easier.
>
> There's a primer and tutorial for nested beans here...
>
>     http://www.keyboardmonkey.com/next
>
>         ...it should take you over creating and using such a construct.
>
> Hope this gets you on th path you're after.

Another area of useful learning for the future is the JSP Standard Tag
Library (JSTL).  Although the expression language syntax supported by JSTL
is different from the one in Struts, it is well worth learning about --
this expression language will be supported anywhere in a JSP page in JSP
1.3, and (in the mean time) we will likely adapt Struts tags to be able to
use it as well.

>
>
> Arron.
>

Craig


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


Re: Nested Tags question

Posted by Arron Bates <st...@keyboardmonkey.com>.
>
>
>I know JSP will automatically save parameters to a javabean with the
>correctly named getters and setters, but there's obviously a gap in my
>knowledge because all my attempts to recreate the situation above have
>failed. 
>

Setting form properties against beans is a Struts thing, not a JSP 
thing. The property thing is a Bean thin and can be looked up in the 
JavaBean spec.

The example you quote...

    "monkeyTeamAlpha.monkeyWorkers[0].salary"

        ...is a nested property. An invention implemented within Struts 
(Craig?). What it basically is, is a string of calls rather than the 
single property method. Here, it will get a hold of the form bean, get a 
hold of the bean returned from the "monkeyTeamAlpha"property. On this 
bean, it will invoke the indexed property "monkeyWorkers[0]" which will 
pluck a bean from a collection or index provided, from this last bean it 
will will get a hold of its "salary" property, and set the value.

All this boils down to, is that you can compose objects a little 
cleaner, rather than have truly enormous beans for everything. Having 
the indexed properties allows for lists and whatever else.

The ability for nesting beans has been in Struts for a long time. The 
nested tags just make it much easier.

There's a primer and tutorial for nested beans here...

    http://www.keyboardmonkey.com/next

        ...it should take you over creating and using such a construct.

Hope this gets you on th path you're after.


Arron.


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


Re: Nested Tags question

Posted by ad...@cyberspaceroad.com.
Hi folks,
I'm going nuts & having a very unproductive day here trying to save
these nested tags as I mentioned earlier. I've boiled down my ignorance
so to speak to the following question:

How or why is the following input tag name / http request param:

monkeyTeamAlpha.monkeyWorkers[0].salary

saved to the MonkeyBean object within an ArrayList monkeyList within a
MonkeyTeamBean within the formbean?

I know JSP will automatically save parameters to a javabean with the
correctly named getters and setters, but there's obviously a gap in my
knowledge because all my attempts to recreate the situation above have
failed. 

I'll go off and try to find something in Sun's JSP specification, but if
anyone can give me a clue, I'd be massively grateful. 

Thanks
Adam



adam.hardy@cyberspaceroad.com schrieb am 12.06.2002, 15:15:30:
> Hi All,
> I am trying to save a list created with the nested:iterate tag (from an
> object array in my form bean). I've written my code by following the
> SaveMonkey example from Arron Bates' KeyboardMonkey site (kudos to you,
> capt'n) - but the object array doesn't get recreated on a submit!
> 
> Can I use a nested:iterate tag on an array straight out of the form
> bean? That seems to be the only difference I can see between mine and
> the SaveMonkey demo.
> 
> The setList(Object[] newList) isn't working. Struts or Tomcat isn't
> recognising it as a normal javabean property setter I guess. Here's what
> the HTML looks like:
> 
> 
>   
>             
> 
> 
> Should I keep looking for a bug that's stopping the setList() method
> from being recognised as a setter method?
> 
> Thanks if you can help,
> Adam
> 
> --
> To unsubscribe, e-mail:   
> For additional commands, e-mail:

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