You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Andreas Joseph Krogh <an...@officenet.no> on 2008/12/11 13:18:20 UTC

Nested-tag support

Hi all!
One of the most usefull things about (2.0 < Struts >= 1.1) is the nested-tag-library. It allows you to do:

<nested:form name="myForm">
  <nested:nest property="person.address">
    <nested:text property="street"/>
  </nested:nest>
</nested:form>

And it will render the following:
<input type="text" name="person.address.street"/>

Strust-2.x lacks this feature and you're responsible for producing the correct "nested-prefix" yourself.
Questing; Was the decition to make the Struts2-tags not work as the nested-tags made on purpose? If so, what the retional for it?

I propose adding this functionality to the existing 2.1 src by doing the following:

- Introduce a property in struts.properties (default false in 2.1, but shold be true or removed in future versions of Struts)
  struts.tag.nested_support=true
  If set to "true", the struts-tags will behave like the good ol' nested-tags.
- Modify existing sources

The s:form equivalent of the nested-example above should be something like:

	<s:form name="myForm">
	  <s:push value="person.address">
		<s:textfield name="street"/>
	  </s:push>
	</s:form>

I believe this is quite simple to implement given that the valuestack is always available and contains everything we need.

Is anyone working on this? Will the community accept such a patch and apply it to mainstream?

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Thursday 11 December 2008 22:42:48 Nils-Helge Garli Hegvik wrote:
> >
> > The s:form equivalent of the nested-example above should be something like:
> >
> >        <s:form name="myForm">
> >          <s:push value="person.address">
> >                <s:textfield name="street"/>
> >          </s:push>
> >        </s:form>
> >
> 
> Wouldn't <s:textfield name="person.address.street"> to the trick?

Yes, ofcourse, but that's exactly what I'm trying to avoid. The point is when you're creating advanced GUIs you don't always know that "full path", so making it possible to include a JSP (jsp:include) for rendering some input-values after having s:push'ed is of tremendous value.

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Yeah, I just didn't understand the question until after I sent the email :)

Nils-H

On Thu, Dec 11, 2008 at 10:56 PM, Musachy Barroso <mu...@gmail.com> wrote:
> it does, but the point it to make it less redundant, when you have
> many fields in one block, like the "with" keyword in some languages
> (Pascal? VB?)
>
> musachy
>
> On Thu, Dec 11, 2008 at 4:42 PM, Nils-Helge Garli Hegvik
> <ni...@gmail.com> wrote:
>>>
>>> The s:form equivalent of the nested-example above should be something like:
>>>
>>>        <s:form name="myForm">
>>>          <s:push value="person.address">
>>>                <s:textfield name="street"/>
>>>          </s:push>
>>>        </s:form>
>>>
>>
>> Wouldn't <s:textfield name="person.address.street"> to the trick?
>>
>> Nils-H
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
>> For additional commands, e-mail: dev-help@struts.apache.org
>>
>>
>
>
>
> --
> "Hey you! Would you help me to carry the stone?" Pink Floyd
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

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


Re: Nested-tag support

Posted by Musachy Barroso <mu...@gmail.com>.
it does, but the point it to make it less redundant, when you have
many fields in one block, like the "with" keyword in some languages
(Pascal? VB?)

musachy

On Thu, Dec 11, 2008 at 4:42 PM, Nils-Helge Garli Hegvik
<ni...@gmail.com> wrote:
>>
>> The s:form equivalent of the nested-example above should be something like:
>>
>>        <s:form name="myForm">
>>          <s:push value="person.address">
>>                <s:textfield name="street"/>
>>          </s:push>
>>        </s:form>
>>
>
> Wouldn't <s:textfield name="person.address.street"> to the trick?
>
> Nils-H
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Nested-tag support

Posted by Musachy Barroso <mu...@gmail.com>.
lmao, we cant be too serious here.

musachy

On Thu, Dec 11, 2008 at 5:21 PM, Dave Newton <ne...@yahoo.com> wrote:
> What is this, some sort of Norwegian revolt?
>
>
> --- On Thu, 12/11/08, Ronny Løvtangen <ro...@lovtangen.com> wrote:
>
>> From: Ronny Løvtangen <ro...@lovtangen.com>
>> Subject: Re: Nested-tag support
>> To: "Struts Developers List" <de...@struts.apache.org>
>> Date: Thursday, December 11, 2008, 5:18 PM
>> On Dec 11, 2008, at 10:42 PM, Nils-Helge Garli Hegvik wrote:
>>
>> >>
>> >> The s:form equivalent of the nested-example above
>> should be something like:
>> >>
>> >>      <s:form name="myForm">
>> >>        <s:push
>> value="person.address">
>> >>              <s:textfield
>> name="street"/>
>> >>        </s:push>
>> >>      </s:form>
>> >>
>> >
>> > Wouldn't <s:textfield
>> name="person.address.street"> to the trick?
>>
>>
>> Yes, but what if you want to reuse code for the form fields
>> for an address and include another jsp? Then you always have
>> to be nested inside person.address, you cant reuse the code
>> if you are inside lets say customer.address.
>>
>> When it really comes in handy is when you operate with
>> collections.
>> Take this example from Struts 1:
>>
>> <nested:nest property="foo">
>>       <nested:iterate property="bars">
>>               <nested:text property="baz"/>
>>       </nested:iterate>
>> </nested:nest>
>>
>> to do the same ting in Struts 2 you have to write:
>>
>> <s:push value="foo">
>>       <s:iterator value="bars"
>> status="status">
>>               <s:textfield
>> name="foo.bars[%{#status.index}].baz"  />
>>       </s:iterator>
>> </s:push>
>>
>> With some changes to the Struts 2 codebase you could write
>>
>> <s:push value="foo">
>>       <s:iterator value="bars">
>>               <s:textfield name="baz"  />
>>       </s:iterator>
>> </s:push>
>>
>> Andreas and I have started to get the example above working
>> on Struts 2. We have some working code, but not all details
>> are figured out yet.
>>
>>
>>
>> --
>> Ronny Løvtangen
>> Senior Consultant - Net Professionals AS
>> ronny@net-pro.no
>> +47 928 21 901
>> http://net-pro.no
>> http://www.linkedin.com/in/ronnylovtangen
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Friday 12 December 2008 01:30:13 Musachy Barroso wrote:
> I second Dave's opinion. Patches are always welcomed.

Great!
Just wanted to make sure that our effort has a chance of being included in "main-struts" before we get on with the task.

You'll hear from us, but it won't be tomorrow:-)

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Musachy Barroso <mu...@gmail.com>.
I second Dave's opinion. Patches are always welcomed.

musachy

On Thu, Dec 11, 2008 at 6:13 PM, Dave Newton <ne...@yahoo.com> wrote:
> --- On Thu, 12/11/08, Andreas Joseph Krogh wrote:
>> Will patches implementing this get accepted?
>
> How can we answer that before getting the patches? I, for one, would probably evaluate such a patch: as long as it doesn't break anything else, and particularly if it solves indexed properties correctly (handling both maps and sequences), I'm interested.
>
> (Actually, I pretty much only care about indexed properties, but I'm sure the other is nice too. Although without trivial validation support for indexed properties it doesn't seem as useful--feel free to throw that in as well!)
>
> Dave
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Nested-tag support

Posted by Dave Newton <ne...@yahoo.com>.
--- On Thu, 12/11/08, Andreas Joseph Krogh wrote:
> Will patches implementing this get accepted?

How can we answer that before getting the patches? I, for one, would probably evaluate such a patch: as long as it doesn't break anything else, and particularly if it solves indexed properties correctly (handling both maps and sequences), I'm interested.

(Actually, I pretty much only care about indexed properties, but I'm sure the other is nice too. Although without trivial validation support for indexed properties it doesn't seem as useful--feel free to throw that in as well!)

Dave


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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Thursday 11 December 2008 23:46:14 Andreas Joseph Krogh wrote:
> On Thursday 11 December 2008 23:40:51 Ronny Løvtangen wrote:
> > 
> > On Dec 11, 2008, at 11:21 PM, Nils-Helge Garli Hegvik wrote:
> > 
> > > As mentioned, I realized that just _after_ pressing the send button,
> > > so please ignore my ignorance ;)
> > 
> > Alright, you're on!
> > For those that aren't, take a look at the original explanation of  
> > nested tags in Struts 1 from Aaron Bates:
> > http://www.keyboardmonkey.com/next/Primer_partOne.jsp?content=yesplease
> 
> The "What if..." in part-2 is especially relevant.

BTW: Musachy's examle of power-OGNL in the iterator tag. Is that even relevant? The "value"-attribute of the iterator-tag is only used to look-up which source to iterate over, so once that source is found I don't see a problem. For the iterator-tag it's only a matter of generating the markup "[<index>]." where you have to maintain this info in some context which you piggy-back on the value-stack (with a separate key) or something.

So, enough explaination (it's getting close to bed-time here...). Is the Struts2-community ready for this functionality in the struts-tags? Will patches implementing this get accepted?

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
Didn't get that far... Couldn't get past requirement a) of part one ;)


Nils-H

On Thu, Dec 11, 2008 at 11:46 PM, Andreas Joseph Krogh
<an...@officenet.no> wrote:
> On Thursday 11 December 2008 23:40:51 Ronny Løvtangen wrote:
>>
>> On Dec 11, 2008, at 11:21 PM, Nils-Helge Garli Hegvik wrote:
>>
>> > As mentioned, I realized that just _after_ pressing the send button,
>> > so please ignore my ignorance ;)
>>
>> Alright, you're on!
>> For those that aren't, take a look at the original explanation of
>> nested tags in Struts 1 from Aaron Bates:
>> http://www.keyboardmonkey.com/next/Primer_partOne.jsp?content=yesplease
>
> The "What if..." in part-2 is especially relevant.
>
> --
> Andreas Joseph Krogh <an...@officenet.no>
> Senior Software Developer / CEO
> ------------------------+---------------------------------------------+
> OfficeNet AS            | The most difficult thing in the world is to |
> Karenslyst Allé 11      | know how to do a thing and to watch         |
> PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
> 0214 Oslo               | comment.                                    |
> NORWAY                  |                                             |
> Tlf:    +47 24 15 38 90 |                                             |
> Fax:    +47 24 15 38 91 |                                             |
> Mobile: +47 909  56 963 |                                             |
> ------------------------+---------------------------------------------+
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Thursday 11 December 2008 23:40:51 Ronny Løvtangen wrote:
> 
> On Dec 11, 2008, at 11:21 PM, Nils-Helge Garli Hegvik wrote:
> 
> > As mentioned, I realized that just _after_ pressing the send button,
> > so please ignore my ignorance ;)
> 
> Alright, you're on!
> For those that aren't, take a look at the original explanation of  
> nested tags in Struts 1 from Aaron Bates:
> http://www.keyboardmonkey.com/next/Primer_partOne.jsp?content=yesplease

The "What if..." in part-2 is especially relevant.

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Ronny Løvtangen <ro...@lovtangen.com>.
On Dec 11, 2008, at 11:21 PM, Nils-Helge Garli Hegvik wrote:

> As mentioned, I realized that just _after_ pressing the send button,
> so please ignore my ignorance ;)

Alright, you're on!
For those that aren't, take a look at the original explanation of  
nested tags in Struts 1 from Aaron Bates:
http://www.keyboardmonkey.com/next/Primer_partOne.jsp?content=yesplease

Ronny

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


Re: Nested-tag support

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
As mentioned, I realized that just _after_ pressing the send button,
so please ignore my ignorance ;)

Nils-H

On Thu, Dec 11, 2008 at 11:18 PM, Ronny Løvtangen <ro...@lovtangen.com> wrote:
>
> On Dec 11, 2008, at 10:42 PM, Nils-Helge Garli Hegvik wrote:
>
>>>
>>> The s:form equivalent of the nested-example above should be something
>>> like:
>>>
>>>     <s:form name="myForm">
>>>       <s:push value="person.address">
>>>             <s:textfield name="street"/>
>>>       </s:push>
>>>     </s:form>
>>>
>>
>> Wouldn't <s:textfield name="person.address.street"> to the trick?
>
>
> Yes, but what if you want to reuse code for the form fields for an address
> and include another jsp? Then you always have to be nested inside
> person.address, you cant reuse the code if you are inside lets say
> customer.address.
>
> When it really comes in handy is when you operate with collections.
> Take this example from Struts 1:
>
> <nested:nest property="foo">
>        <nested:iterate property="bars">
>                <nested:text property="baz"/>
>        </nested:iterate>
> </nested:nest>
>
> to do the same ting in Struts 2 you have to write:
>
> <s:push value="foo">
>        <s:iterator value="bars" status="status">
>                <s:textfield name="foo.bars[%{#status.index}].baz"  />
>        </s:iterator>
> </s:push>
>
> With some changes to the Struts 2 codebase you could write
>
> <s:push value="foo">
>        <s:iterator value="bars">
>                <s:textfield name="baz"  />
>        </s:iterator>
> </s:push>
>
> Andreas and I have started to get the example above working on Struts 2. We
> have some working code, but not all details are figured out yet.
>
>
>
> --
> Ronny Løvtangen
> Senior Consultant - Net Professionals AS
> ronny@net-pro.no
> +47 928 21 901
> http://net-pro.no
> http://www.linkedin.com/in/ronnylovtangen
>

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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Thursday 11 December 2008 23:21:23 Dave Newton wrote:
> What is this, some sort of Norwegian revolt?

You're on!

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Dave Newton <ne...@yahoo.com>.
What is this, some sort of Norwegian revolt?


--- On Thu, 12/11/08, Ronny Løvtangen <ro...@lovtangen.com> wrote:

> From: Ronny Løvtangen <ro...@lovtangen.com>
> Subject: Re: Nested-tag support
> To: "Struts Developers List" <de...@struts.apache.org>
> Date: Thursday, December 11, 2008, 5:18 PM
> On Dec 11, 2008, at 10:42 PM, Nils-Helge Garli Hegvik wrote:
> 
> >> 
> >> The s:form equivalent of the nested-example above
> should be something like:
> >> 
> >>      <s:form name="myForm">
> >>        <s:push
> value="person.address">
> >>              <s:textfield
> name="street"/>
> >>        </s:push>
> >>      </s:form>
> >> 
> > 
> > Wouldn't <s:textfield
> name="person.address.street"> to the trick?
> 
> 
> Yes, but what if you want to reuse code for the form fields
> for an address and include another jsp? Then you always have
> to be nested inside person.address, you cant reuse the code
> if you are inside lets say customer.address.
> 
> When it really comes in handy is when you operate with
> collections.
> Take this example from Struts 1:
> 
> <nested:nest property="foo">
> 	<nested:iterate property="bars">
> 		<nested:text property="baz"/>
> 	</nested:iterate>
> </nested:nest>
> 
> to do the same ting in Struts 2 you have to write:
> 
> <s:push value="foo">
> 	<s:iterator value="bars"
> status="status">
> 		<s:textfield
> name="foo.bars[%{#status.index}].baz"  />
> 	</s:iterator>
> </s:push>
> 
> With some changes to the Struts 2 codebase you could write
> 
> <s:push value="foo">
> 	<s:iterator value="bars">
> 		<s:textfield name="baz"  />
> 	</s:iterator>
> </s:push>
> 
> Andreas and I have started to get the example above working
> on Struts 2. We have some working code, but not all details
> are figured out yet.
> 
> 
> 
> --
> Ronny Løvtangen
> Senior Consultant - Net Professionals AS
> ronny@net-pro.no
> +47 928 21 901
> http://net-pro.no
> http://www.linkedin.com/in/ronnylovtangen

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


Re: Nested-tag support

Posted by Ronny Løvtangen <ro...@lovtangen.com>.
On Dec 11, 2008, at 10:42 PM, Nils-Helge Garli Hegvik wrote:

>>
>> The s:form equivalent of the nested-example above should be  
>> something like:
>>
>>      <s:form name="myForm">
>>        <s:push value="person.address">
>>              <s:textfield name="street"/>
>>        </s:push>
>>      </s:form>
>>
>
> Wouldn't <s:textfield name="person.address.street"> to the trick?


Yes, but what if you want to reuse code for the form fields for an  
address and include another jsp? Then you always have to be nested  
inside person.address, you cant reuse the code if you are inside lets  
say customer.address.

When it really comes in handy is when you operate with collections.
Take this example from Struts 1:

<nested:nest property="foo">
	<nested:iterate property="bars">
		<nested:text property="baz"/>
	</nested:iterate>
</nested:nest>

to do the same ting in Struts 2 you have to write:

<s:push value="foo">
	<s:iterator value="bars" status="status">
		<s:textfield name="foo.bars[%{#status.index}].baz"  />
	</s:iterator>
</s:push>

With some changes to the Struts 2 codebase you could write

<s:push value="foo">
	<s:iterator value="bars">
		<s:textfield name="baz"  />
	</s:iterator>
</s:push>

Andreas and I have started to get the example above working on Struts  
2. We have some working code, but not all details are figured out yet.



--
Ronny Løvtangen
Senior Consultant - Net Professionals AS
ronny@net-pro.no
+47 928 21 901
http://net-pro.no
http://www.linkedin.com/in/ronnylovtangen

Re: Nested-tag support

Posted by Nils-Helge Garli Hegvik <ni...@gmail.com>.
>
> The s:form equivalent of the nested-example above should be something like:
>
>        <s:form name="myForm">
>          <s:push value="person.address">
>                <s:textfield name="street"/>
>          </s:push>
>        </s:form>
>

Wouldn't <s:textfield name="person.address.street"> to the trick?

Nils-H

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


Re: Nested-tag support

Posted by Musachy Barroso <mu...@gmail.com>.
> Have you ever used the nested-tags in Struts-1.1?

Just for a few months to add it to my resume :)

> This example is rather simple, but in much more complicated forms, inside iterators for example, where you want to reuse JSPs it is >*extremely* useful to avoid code-douplication. Much easier to generate dynamic user-interfaces this way. The philosophy is "as long as >I'm inside this nested-context I know I can render this piece of code regardless of the object-hierarchy the object resides in".

I understand, but I still don't get why the push tag is not enough.

musachy

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


Re: Nested-tag support

Posted by Dave Newton <ne...@yahoo.com>.
--- On Thu, 12/11/08, Andreas Joseph Krogh wrote:
> On Thursday 11 December 2008 22:36:37 Musachy Barroso wrote:
> > I am sort if confused here, what are the advantages of this?
> <s:form name="myForm">
>   <s:push value="person.address">
>     <s:textfield name="street"/>
>   </s:push>
> [...]

The issue is the generation of the form element name, the input element value stuff would already work.

If push kept a stack of the names of pushed elements it could be used to generate the "name" attribute--but wouldn't you'd have to correlate with the depth at which getStreet() was found?

Let's say person.address didn't have a "street" property: currently the value stack would be searched until a getStreet() is found or the stack runs out. So you'd have to either change the semantics of value stack lookups (bad, and would break modelDriven, and probably a bunch of other things) or provide a way to match pushed objects' names with where objects are found on the stack.

That paragraph made sense in my head, and I'm pretty sure I know what I mean, but it's not coming out particularly well.

Dave


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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Thursday 11 December 2008 22:36:37 Musachy Barroso wrote:
> I am sort if confused here, what are the advantages of this?

Have you ever used the nested-tags in Struts-1.1?
The advantage is that the value of the "name"-attribute is calculated for you.

That way you can write:
       <s:form name="myForm">
         <s:push value="person.address">
               <s:textfield name="street"/>
         </s:push>
       </s:form>
Notice the inner s:textfield is only specifying name="street" which is enough to render name="person.address.street" because it knows it's inside the address-object (s:push).

This example is rather simple, but in much more complicated forms, inside iterators for example, where you want to reuse JSPs it is *extremely* useful to avoid code-douplication. Much easier to generate dynamic user-interfaces this way. The philosophy is "as long as I'm inside this nested-context I know I can render this piece of code regardless of the object-hierarchy the object resides in".


-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Musachy Barroso <mu...@gmail.com>.
I am sort if confused here, what are the advantages of this?

musachy

On Thu, Dec 11, 2008 at 4:32 PM, Andreas Joseph Krogh
<an...@officenet.no> wrote:
> Anyone?
> I really would like to see this included sooner than later and would appreciate any feedback.
>
> On Thursday 11 December 2008 13:18:20 Andreas Joseph Krogh wrote:
>> Hi all!
>> One of the most usefull things about (2.0 < Struts >= 1.1) is the nested-tag-library. It allows you to do:
>>
>> <nested:form name="myForm">
>>   <nested:nest property="person.address">
>>     <nested:text property="street"/>
>>   </nested:nest>
>> </nested:form>
>>
>> And it will render the following:
>> <input type="text" name="person.address.street"/>
>>
>> Strust-2.x lacks this feature and you're responsible for producing the correct "nested-prefix" yourself.
>> Questing; Was the decition to make the Struts2-tags not work as the nested-tags made on purpose? If so, what the retional for it?
>>
>> I propose adding this functionality to the existing 2.1 src by doing the following:
>>
>> - Introduce a property in struts.properties (default false in 2.1, but shold be true or removed in future versions of Struts)
>>   struts.tag.nested_support=true
>>   If set to "true", the struts-tags will behave like the good ol' nested-tags.
>> - Modify existing sources
>>
>> The s:form equivalent of the nested-example above should be something like:
>>
>>       <s:form name="myForm">
>>         <s:push value="person.address">
>>               <s:textfield name="street"/>
>>         </s:push>
>>       </s:form>
>>
>> I believe this is quite simple to implement given that the valuestack is always available and contains everything we need.
>>
>> Is anyone working on this? Will the community accept such a patch and apply it to mainstream?
>>
>
>
>
> --
> Andreas Joseph Krogh <an...@officenet.no>
> Senior Software Developer / CEO
> ------------------------+---------------------------------------------+
> OfficeNet AS            | The most difficult thing in the world is to |
> Karenslyst Allé 11      | know how to do a thing and to watch         |
> PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
> 0214 Oslo               | comment.                                    |
> NORWAY                  |                                             |
> Tlf:    +47 24 15 38 90 |                                             |
> Fax:    +47 24 15 38 91 |                                             |
> Mobile: +47 909  56 963 |                                             |
> ------------------------+---------------------------------------------+
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>



-- 
"Hey you! Would you help me to carry the stone?" Pink Floyd

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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
Anyone?
I really would like to see this included sooner than later and would appreciate any feedback.

On Thursday 11 December 2008 13:18:20 Andreas Joseph Krogh wrote:
> Hi all!
> One of the most usefull things about (2.0 < Struts >= 1.1) is the nested-tag-library. It allows you to do:
> 
> <nested:form name="myForm">
>   <nested:nest property="person.address">
>     <nested:text property="street"/>
>   </nested:nest>
> </nested:form>
> 
> And it will render the following:
> <input type="text" name="person.address.street"/>
> 
> Strust-2.x lacks this feature and you're responsible for producing the correct "nested-prefix" yourself.
> Questing; Was the decition to make the Struts2-tags not work as the nested-tags made on purpose? If so, what the retional for it?
> 
> I propose adding this functionality to the existing 2.1 src by doing the following:
> 
> - Introduce a property in struts.properties (default false in 2.1, but shold be true or removed in future versions of Struts)
>   struts.tag.nested_support=true
>   If set to "true", the struts-tags will behave like the good ol' nested-tags.
> - Modify existing sources
> 
> The s:form equivalent of the nested-example above should be something like:
> 
> 	<s:form name="myForm">
> 	  <s:push value="person.address">
> 		<s:textfield name="street"/>
> 	  </s:push>
> 	</s:form>
> 
> I believe this is quite simple to implement given that the valuestack is always available and contains everything we need.
> 
> Is anyone working on this? Will the community accept such a patch and apply it to mainstream?
> 



-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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


Re: Nested-tag support

Posted by Andreas Joseph Krogh <an...@officenet.no>.
On Thursday 11 December 2008 23:07:53 Musachy Barroso wrote:
> Now I see what you mean. What 'push' does is to put a value on top of
> the stack. The name attribute is a string, not an expression, and
> doesn't use the stack for anything. That is why it wouldn't work.

Yes, that's why it doesn't work:-) And what I'm proposing is to fix it to make it work by introdusing a concept of a "NestedContext" which is updated by the relevant tags (push, iterate) when appropriate and used by the UIBean to write out the "name"-attribute for the input-tag. Something like this in evaluateParams():

        if (this.name != null) {
            name = findString(this.name);
            addParameter("name", NestedContextHelper.computeNesting(stack)+findString(name));
        }

-- 
Andreas Joseph Krogh <an...@officenet.no>
Senior Software Developer / CEO
------------------------+---------------------------------------------+
OfficeNet AS            | The most difficult thing in the world is to |
Karenslyst Allé 11      | know how to do a thing and to watch         |
PO. Box 529 Skøyen      | somebody else doing it wrong, without       |
0214 Oslo               | comment.                                    |
NORWAY                  |                                             |
Tlf:    +47 24 15 38 90 |                                             |
Fax:    +47 24 15 38 91 |                                             |
Mobile: +47 909  56 963 |                                             |
------------------------+---------------------------------------------+

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