You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Don Brown <do...@gmail.com> on 2006/12/01 09:21:01 UTC

Re: [s2] Simple Tag Question and

Why do you need to modify?  What about just pushing something else
that effectively overrides the existing value?

Don

On 8/30/06, Mark Menard <ma...@mjm.net> wrote:
> Is this following possible?
>
> <s:bean name="java.util.HashMap" id="qTableLayout">
> </s:bean>
> <s:push value="#qTableLayout">
>     <s:param name="tablecolspan" value="%{4}" />
>     <s:param name="currentColumnCount" value="%{0}" />
> </s:push>
>
>
> If it isn't how do you change the value of something on the value stack once
> you are either into a JSP or in a FreeMarker template?
>
> I have been struggling with this for days now. I know it's got to be
> something really really really stupidly simple, but I'm just not seeing it.
> I've read WebWork in Action, read a lot of the component and view.jsp code.
> I just don't understand how you use these tags to modify the value of
> something on the stack.
>
> Thanks,
>
> Mark
>
> ---------------------------------------------------------------------
> 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: [s2] Simple Tag Question and

Posted by Don Brown <do...@gmail.com>.
On 12/1/06, Mark Menard <ma...@mjm.net> wrote:
> On 12/1/06 12:01 PM, "Don Brown" <do...@gmail.com> wrote:
>
> > Well, I had some free time (holding my new son to let mom get some
> > sleep) and figured everyone deserved at least a reply.  Yay for
> > GMail's search.
> >
> > Anyways, cool, thanks for the update.  I don't know of a better tag,
> > but we are always open for a patch... :)
>
> Ok, I was thinking of that when I wrote that email this morning. We have
> <s:set>, <s:bean>, and <s:push>. How about something that would just let you
> run an expression against the value stack. As a beginner I would have
> thought that <s:set> would do that, but it doesn't seem to.
>
> So, my thought is a tag that I could pass: "#myMap['myProperty'] =
> somevalue" to actually process the expression against the stack. Maybe:
>
>     <s:evaluate value="#myMap['myProperty'] = somevalue" />

Makes sense to me.  Put together a proposal on dev, or better yet, a
JIRA ticket with patch, and we'll see what others think.

> In a related vein I would like to add some default properties to the UI
> tags. Currently I'm passing these things into my template using <s:param>
> tags. I'd like to be able to do the following though:
>
>     <s:textfield name="someProperty" inputcolspan="2" />
>
> Any idea where I would start with this?

This is a trickier problem.  With JSP 2.0 IIRC, they support the
concept of attributes that aren't defined in the TLD.  The problem
here is that then the tag becomes less useful to tools that provide
autocompletion.  Stripes solves this problem by providing two sets of
tags - same tags but different TLDs - so you can use the non-varargs
ones by default but then switch to the varargs when necessary.  If you
think Struts 2 should have this, start a thread on dev@.

HTH,

Don
> Thanks,
>
> Mark
>
> ---------------------------------------------------------------------
> 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: [s2] Simple Tag Question and

Posted by Mark Menard <ma...@mjm.net>.
On 12/1/06 12:01 PM, "Don Brown" <do...@gmail.com> wrote:

> Well, I had some free time (holding my new son to let mom get some
> sleep) and figured everyone deserved at least a reply.  Yay for
> GMail's search.
> 
> Anyways, cool, thanks for the update.  I don't know of a better tag,
> but we are always open for a patch... :)

Ok, I was thinking of that when I wrote that email this morning. We have
<s:set>, <s:bean>, and <s:push>. How about something that would just let you
run an expression against the value stack. As a beginner I would have
thought that <s:set> would do that, but it doesn't seem to.

So, my thought is a tag that I could pass: "#myMap['myProperty'] =
somevalue" to actually process the expression against the stack. Maybe:

    <s:evaluate value="#myMap['myProperty'] = somevalue" />

In a related vein I would like to add some default properties to the UI
tags. Currently I'm passing these things into my template using <s:param>
tags. I'd like to be able to do the following though:

    <s:textfield name="someProperty" inputcolspan="2" />

Any idea where I would start with this?

Thanks,

Mark

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


Re: [s2] Simple Tag Question and

Posted by Don Brown <do...@gmail.com>.
Well, I had some free time (holding my new son to let mom get some
sleep) and figured everyone deserved at least a reply.  Yay for
GMail's search.

Anyways, cool, thanks for the update.  I don't know of a better tag,
but we are always open for a patch... :)

Don

On 12/1/06, Mark Menard <ma...@mjm.net> wrote:
> On 12/1/06 3:21 AM, "Don Brown" <do...@gmail.com> wrote:
> >
> > On 8/30/06, Mark Menard <ma...@mjm.net> wrote:
> >> Is this following possible?
> >>
> >> <s:bean name="java.util.HashMap" id="qTableLayout">
> >> </s:bean>
> >> <s:push value="#qTableLayout">
> >>     <s:param name="tablecolspan" value="%{4}" />
> >>     <s:param name="currentColumnCount" value="%{0}" />
> >> </s:push>
> >>
> >>
> >> If it isn't how do you change the value of something on the value stack once
> >> you are either into a JSP or in a FreeMarker template?
> >
> > Why do you need to modify?  What about just pushing something else
> > that effectively overrides the existing value?
>
> Don,
>
> Wow! You went back quite a ways to find this issue.
>
> I guess I could have done that. It didn't seem obvious to me at the time,
> nor does it seem efficient, creating a Map for one invocation of a
> FreeMarker template and then just throwing it away, when just updating a
> property within the Map would do.
>
> Background. I was working on a theme that would automatically handle
> multi-column layout of forms. I used the qTableLayout Map to hold my
> configuration, tablecolspan, and the current state of the table,
> currentColumnCount. I needed to be able to modify currentColumnCount from
> within my FreeMarker templates, so the various templates would know if they
> needed to emit either an open <tr> or a close </tr>.
>
> My issue when I wrote that email was I couldn't figure out how to update the
> currentColumnCount insided the qTableLayout Map. tm_jee on the WW forum
> pointed out that I could do the following in my FreeMarker template:
>
>     ${stack.setValue('#qTableLayout.currentColumnCount', columnCount)}
>
> To a complete beginner this wasn't obvious. I was struggling with the fact
> that FreeMarker couldn't change the "model". So, I figured there would be a
> way to do that using the WW/S2 tags, which I couldn't figure out. The thread
> on the WW forum is:
>
>     http://forums.opensymphony.com/thread.jspa?messageID=83553
>
> If there is a tag equivalent of stack.setValue ("#someMap.someProperty",
> value) I'd be curious.
>
> You can see an example of what I got working at:
>
>     http://www.vitarara.org/cms/node/74
>
> Don't take the commentary in there to seriously I was very tired and cranky
> at the time. This functionality seemed so obviously needed on its face to
> me, but I just couldn't figure out how to make it work. Anyway, it works
> today, and it's a lot more sophisticated. I have support for variable label
> and input column spans. I might also work in variable row span support if I
> find I need it. I'm currently working on a tutorial covering what I did.
> I'll post the link when I get done.
>
> Thanks,
>
> Mark
>
> ---------------------------------------------------------------------
> 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: [s2] Simple Tag Question and

Posted by Mark Menard <ma...@mjm.net>.
On 12/1/06 3:21 AM, "Don Brown" <do...@gmail.com> wrote:
>
> On 8/30/06, Mark Menard <ma...@mjm.net> wrote:
>> Is this following possible?
>> 
>> <s:bean name="java.util.HashMap" id="qTableLayout">
>> </s:bean>
>> <s:push value="#qTableLayout">
>>     <s:param name="tablecolspan" value="%{4}" />
>>     <s:param name="currentColumnCount" value="%{0}" />
>> </s:push>
>> 
>> 
>> If it isn't how do you change the value of something on the value stack once
>> you are either into a JSP or in a FreeMarker template?
>
> Why do you need to modify?  What about just pushing something else
> that effectively overrides the existing value?

Don,

Wow! You went back quite a ways to find this issue.

I guess I could have done that. It didn't seem obvious to me at the time,
nor does it seem efficient, creating a Map for one invocation of a
FreeMarker template and then just throwing it away, when just updating a
property within the Map would do.

Background. I was working on a theme that would automatically handle
multi-column layout of forms. I used the qTableLayout Map to hold my
configuration, tablecolspan, and the current state of the table,
currentColumnCount. I needed to be able to modify currentColumnCount from
within my FreeMarker templates, so the various templates would know if they
needed to emit either an open <tr> or a close </tr>.

My issue when I wrote that email was I couldn't figure out how to update the
currentColumnCount insided the qTableLayout Map. tm_jee on the WW forum
pointed out that I could do the following in my FreeMarker template:

    ${stack.setValue('#qTableLayout.currentColumnCount', columnCount)}

To a complete beginner this wasn't obvious. I was struggling with the fact
that FreeMarker couldn't change the "model". So, I figured there would be a
way to do that using the WW/S2 tags, which I couldn't figure out. The thread
on the WW forum is:

    http://forums.opensymphony.com/thread.jspa?messageID=83553

If there is a tag equivalent of stack.setValue ("#someMap.someProperty",
value) I'd be curious.

You can see an example of what I got working at:

    http://www.vitarara.org/cms/node/74

Don't take the commentary in there to seriously I was very tired and cranky
at the time. This functionality seemed so obviously needed on its face to
me, but I just couldn't figure out how to make it work. Anyway, it works
today, and it's a lot more sophisticated. I have support for variable label
and input column spans. I might also work in variable row span support if I
find I need it. I'm currently working on a tutorial covering what I did.
I'll post the link when I get done.

Thanks,

Mark

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