Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change 
notification.

The following page has been changed by MichaelJouravlev:
http://wiki.apache.org/struts/StrutsTags

New page:
This page contains FAQ on Struts, Struts-EL, JSTL and Ajax tags. The separation 
between these categories is rather fluid, because it is possible to mix and 
match tags, for example to use JSTL tags or scriptlets within Struts tags. 
Therefore, please look in all categories.

== Struts tags ==

=== NPE when accessing value using scriptlet ===
Q: I use the following code in a jsp:

{{{
 <logic:present name="person">
   <html:text property="name" " value='<%= person.getName() %>'/>
 </logic:present>
}}}

If 'person' is not present <%= person.getName() %> is compiled and I get
this error: membreLIFL cannot be resolved

If i use this code:

{{{
 <logic:present name="person">
   <input type="text" name="name" 
          value="<bean:write name="person" property="name"/>"
   />
 </logic:present>
}}}

No problem. How can i use the html:text tag?

A: JSP scriptlet is a regular Java code, which calls a method on "person" 
object. If "person" object is not defined, an NPE is generated. 

Choice 1: If you use JSP 2.3 + Struts-EL or JSP 2.4, you can use the following 
syntax to access "name" property:
{{{
 <html-el:text property="name" value="${person.name}" />
}}}
JSTL does not throw NPE if you accessing a property of non-existing object.

Choice 2: If a Struts tag defines "value" attribute, it is possible to use 
either this attribute or text element of a tag. The following definitions are 
equivalent:

{{{
 <html:text property="name" value="someData"/>
}}}

and 

{{{
 <html:text property="name">
   someData
 </html:text>
}}}

== Struts-EL tags ==

== JSTL tags ==

== JSP scriptlets ==

== Ajax Tags ==

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to