Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Stuct

0 views
Skip to first unread message

kaps

unread,
Sep 7, 2010, 7:10:20 AM9/7/10
to
Struts <s:textfield> tags 'value' field
Why Struts 2 tag <s:textfield> do not accept value="xxx" like ;

Ex: <s:textfield name="empname" value="PPP"/> This line in JSP will
throw TLD exception.


While with HTML it works fine.

Ex:<input type="text" name="empname" value="PPP" />

Lew

unread,
Sep 7, 2010, 8:38:48 AM9/7/10
to

Those are two entirely different tags. W3schools has a good summary of legal
attributes for HTML tags. The Struts project documents the legal attributes
for their tags. The documentation will make it clear.

Re: your subject line. What is a "Stuct"? I guess "Struct" initially, now I
see you're discussing "Struts", and it occurs to me you might have meant
"Stuck", but it isn't clear if any of those or something else were meant.

--
Lew

Arne Vajhøj

unread,
Sep 7, 2010, 6:33:29 PM9/7/10
to
On 07-09-2010 07:10, kaps wrote:
> Struts<s:textfield> tags 'value' field
> Why Struts 2 tag<s:textfield> do not accept value="xxx" like ;
>
> Ex:<s:textfield name="empname" value="PPP"/> This line in JSP will
> throw TLD exception.

Weird because according to docs then textfield does have
a value attribute.

http://struts.apache.org/2.0.12/docs/textfield.html

What is the exact exception you get?

> While with HTML it works fine.
>
> Ex:<input type="text" name="empname" value="PPP" />

That is not relevant.

Arne

Ken

unread,
Sep 8, 2010, 3:03:02 PM9/8/10
to

Such a line is fine.
Since you're getting a Tag Library Definition error...
You do have this line at the top of your JSP:
<%@taglib prefix="s" uri="/struts-tags" %>

and you do have the required struts Jar's on the class path,
namely: struts-taglib-x.y.z.jar where x y z are version numbers
for the version you're using?

Anyways this is something to consider later, strings in
struts 2 tags are evaluated as OGNL expressions...
so it might be clearer to write:
value="%{'PPP'}" if you mean the string PPP rather than
having it look for a property called PPP on the value stack
first... although this will not cause a TLD exception,
it simply might produce the wrong result.

Also there isn't anything wrong with using the HTML tag with struts 2.
Sometimes it's more convenient.
The <s:textfield> tag simply creates an html <textfield> tag...
By switching the Struts 2 theme to AJAX you can get simple
AJAX support as it will render the page with the required JavaScript
(there are other modes)...
mind you this is only for simple things... There really is no
requirement
to use struts UI tags in order to use Struts 2 actions.

So go ahead and use: <input type="text" name="empname" value="PPP" />
if you want.
The action tied to the submit button will have the setter: setEmpname
called
and will have the value of the text field passed in.

0 new messages