Chris Pratt wrote:
Like Neil suggested, use attrib.length() The extra parens cause OGNL to
call getAttrib().length() rather than getAttrib().getLength().
(*Chris*)
Thanks, that does work in that the textfield re-sizes according to the
length of the string. Doesn't help unfortunately
Doesn't help unfortunately as the
length of the string
in characters is not the same as the space required to
display it in full!
Have you tried adding 2 or 3 to the length value?
Neil
--
Neil Aggarwal, (281)846-8957, http://UnmeteredVPS.net
Host your struts app on a CentOS VPS
For this example pretend your field firstname has a max length of 15:
s:textfield name=firstname maxlength=15 /
-Original Message-
From: RogerV [mailto:roger.var...@googlemail.com]
Sent: Monday, November 16, 2009 10:29 AM
To: user@struts.apache.org
Subject: OGNL expression help
Could someone show me the correct way to insert a string
field length into
the size attribute of a s:textfield element.
s:textfield name=firstname maxlength=15 /
I think he was looking for something more involved,
something like:
s:textfield name=firstname size=%{myString.length()} /
Kawczynski, David wrote:
For this example pretend your field firstname has a max length of 15:
s:textfield name=firstname maxlength=15 /
LOL :) I suspect that my difficulties in trying to use OGNL to insert the
length are related to the fact that the method call on a string is
length are related to the fact that the method call on a string is
String.length() not String.getLength and when I use
size=%{attrib.length}
OGNL is trying to call getAttrib().getLength() on my action
You could create your own MyString class that
extends String and then have a getLength()
Like Neil suggested, use attrib.length() The extra parens cause OGNL to
call getAttrib().length() rather than getAttrib().getLength().
(*Chris*)
On Mon, Nov 16, 2009 at 8:08 AM, RogerV roger.var...@googlemail.com wrote:
Kawczynski, David wrote:
For this example pretend your field
2009/11/16 Neil Aggarwal n...@jammconsulting.com:
You could create your own MyString class that
extends String and then have a getLength() method
that calls super.length().
Extending String? String is final so it isn't doable ;-)
Regards
--
Lukasz
http://www.lenart.org.pl/
Extending String? String is final so it isn't doable ;-)
I did not check that.
I see someone posted a better solution than this but
I guess if someone wanted to have a getLength() for
a String, they could write a container class that
holds a String and then implement all the methods to
call
9 matches
Mail list logo