You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jim Talbut <Ji...@groupgti.com> on 2010/02/04 20:27:28 UTC
Dynamic values for rows attribute of s:textarea
Hi,
I have:
<s:textarea label="Request Definition" name="requestDefinition" labelSeparator="" labelposition="left" readonly="true" cols="80" rows="5" />
Sometimes I have a LOT of data to display in the box, other times I have none at all.
I'd like the box to resize based on the amount of data.
My best effort involved getting the length of requestDefinition (using s:set), calculating a decent row count based on that and then trying to set the rows="<%=len%>"
Unfortunately that's against the DTD and struts blows up.
Apart from a long series of ugly s:if elements is there any way to get a dynamic rowcount?
I may resort to use javascript, but that'd be quite a faff (these textareas are in a series of forms generated by an iterator).
Thanks
Jim
RE: Dynamic values for rows attribute of s:textarea
Posted by Jim Talbut <Ji...@groupgti.com>.
That's it, thank you.
<s:set var="len" value="requestDefinition == null ? 1 : ( requestDefinition.length() > 49 ? requestDefinition.length() / 50 : 1 )" />
<s:textarea label="Request Definition" name="requestDefinition" labelSeparator="" labelposition="left" readonly="true" cols="80" rows="%{#len}" />
Jim
-----Original Message-----
From: Wes Wannemacher [mailto:wesw@wantii.com]
Sent: 04 February 2010 20:08
To: Struts Users Mailing List
Subject: Re: Dynamic values for rows attribute of s:textarea
If you're calculating your value with s:set and setting a variable
called, "len" did you try the following -
<s:textarea label="Request Definition"
name="requestDefinition"
labelSeparator=""
labelposition="left"
readonly="true"
cols="80"
rows="%{#len}" />
On Thu, Feb 4, 2010 at 2:27 PM, Jim Talbut <Ji...@groupgti.com> wrote:
> Hi,
>
> I have:
> <s:textarea label="Request Definition" name="requestDefinition" labelSeparator="" labelposition="left" readonly="true" cols="80" rows="5" />
> Sometimes I have a LOT of data to display in the box, other times I have none at all.
> I'd like the box to resize based on the amount of data.
>
> My best effort involved getting the length of requestDefinition (using s:set), calculating a decent row count based on that and then trying to set the rows="<%=len%>"
> Unfortunately that's against the DTD and struts blows up.
>
> Apart from a long series of ugly s:if elements is there any way to get a dynamic rowcount?
>
> I may resort to use javascript, but that'd be quite a faff (these textareas are in a series of forms generated by an iterator).
>
> Thanks
>
> Jim
>
>
--
Wes Wannemacher
Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!
---------------------------------------------------------------------
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: Dynamic values for rows attribute of s:textarea
Posted by Wes Wannemacher <we...@wantii.com>.
If you're calculating your value with s:set and setting a variable
called, "len" did you try the following -
<s:textarea label="Request Definition"
name="requestDefinition"
labelSeparator=""
labelposition="left"
readonly="true"
cols="80"
rows="%{#len}" />
On Thu, Feb 4, 2010 at 2:27 PM, Jim Talbut <Ji...@groupgti.com> wrote:
> Hi,
>
> I have:
> <s:textarea label="Request Definition" name="requestDefinition" labelSeparator="" labelposition="left" readonly="true" cols="80" rows="5" />
> Sometimes I have a LOT of data to display in the box, other times I have none at all.
> I'd like the box to resize based on the amount of data.
>
> My best effort involved getting the length of requestDefinition (using s:set), calculating a decent row count based on that and then trying to set the rows="<%=len%>"
> Unfortunately that's against the DTD and struts blows up.
>
> Apart from a long series of ugly s:if elements is there any way to get a dynamic rowcount?
>
> I may resort to use javascript, but that'd be quite a faff (these textareas are in a series of forms generated by an iterator).
>
> Thanks
>
> Jim
>
>
--
Wes Wannemacher
Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org