You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by The_Developer <ab...@gmail.com> on 2008/01/21 10:12:23 UTC
Scriplets not working in tags
Hi,
I've been trying to use scriptlets and/or <bean:write> tags inside
<html:select onchange=""> and <html:button onclick=""> tags. However it
seems that in either case the expression is not evaluated at runtime. The
end result is something like this
<html:select onchange="javascript:update('<bean:write
name='productId'/>)">abc</html:select> and
<html:button onclick="javascript:update('<bean:write name='productId'/>)"/>
when the I intended the output to be something like
<html:select onchange="javascript:update('5)">abc</html:select> and
<html:button onclick="javascript:update('5')"/>
Does anyone know why this is happening or am I making a mistake?
Many Thanks
--
View this message in context: http://www.nabble.com/Scriplets-not-working-in-%3Chtml%3Axyz%3E-tags-tp14993571p14993571.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Scriplets not working in tags
Posted by Laurie Harper <la...@holoweb.net>.
Again, it's a JSP syntax issue. onchange="update('<%=i%>')" should be
onchange='<%="update("+i+")"%>' instead. RT expressions can't be mixed
with plain text.
On the other hand, JSTL expressions *can* be used that way. This would
also work (assuming you have JSTL configured/available):
onchange="update('${i}')".
L.
The_Developer wrote:
> Thanks Laurie,
>
> I tried the solution you gave but to no avail. Here's what i did,
>
> <%
> int i=0;
> %>
>
> <html:select property="ewPrdProduct" onchange="update('<%=i
> %>')" name="ProductPricelistForm" styleClass="inputbox">
> <html:options collection="beansList" property="value"
> labelProperty="label" />
> </html:select>
>
> and the resulting output was,
>
> <select name="ewPrdProduct" onchange="update('<%=i %>')" class="inputbox">
>
> I tried this before also and got the same output which is why I am confused.
>
> The_Developer
>
>
> The_Developer wrote:
>> Hi,
>>
>> I've been trying to use scriptlets and/or <bean:write> tags inside
>> <html:select onchange=""> and <html:button onclick=""> tags. However it
>> seems that in either case the expression is not evaluated at runtime. The
>> end result is something like this
>>
>> <html:select onchange="javascript:update('<bean:write
>> name='productId'/>)">abc</html:select> and
>> <html:button onclick="javascript:update('<bean:write
>> name='productId'/>)"/>
>>
>> when the I intended the output to be something like
>>
>> <html:select onchange="javascript:update('5)">abc</html:select> and
>> <html:button onclick="javascript:update('5')"/>
>>
>> Does anyone know why this is happening or am I making a mistake?
>>
>> Many Thanks
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Scriplets not working in tags
Posted by The_Developer <ab...@gmail.com>.
Thanks Laurie,
I tried the solution you gave but to no avail. Here's what i did,
<%
int i=0;
%>
<html:select property="ewPrdProduct" onchange="update('<%=i
%>')" name="ProductPricelistForm" styleClass="inputbox">
<html:options collection="beansList" property="value"
labelProperty="label" />
</html:select>
and the resulting output was,
<select name="ewPrdProduct" onchange="update('<%=i %>')" class="inputbox">
I tried this before also and got the same output which is why I am confused.
The_Developer
The_Developer wrote:
>
> Hi,
>
> I've been trying to use scriptlets and/or <bean:write> tags inside
> <html:select onchange=""> and <html:button onclick=""> tags. However it
> seems that in either case the expression is not evaluated at runtime. The
> end result is something like this
>
> <html:select onchange="javascript:update('<bean:write
> name='productId'/>)">abc</html:select> and
> <html:button onclick="javascript:update('<bean:write
> name='productId'/>)"/>
>
> when the I intended the output to be something like
>
> <html:select onchange="javascript:update('5)">abc</html:select> and
> <html:button onclick="javascript:update('5')"/>
>
> Does anyone know why this is happening or am I making a mistake?
>
> Many Thanks
>
--
View this message in context: http://www.nabble.com/Scriplets-not-working-in-%3Chtml%3Axyz%3E-tags-tp14993571p15012971.html
Sent from the Struts - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Scriplets not working in tags
Posted by Laurie Harper <la...@holoweb.net>.
The_Developer wrote:
> Hi,
>
> I've been trying to use scriptlets and/or <bean:write> tags inside
> <html:select onchange=""> and <html:button onclick=""> tags. However it
> seems that in either case the expression is not evaluated at runtime. The
> end result is something like this
>
> <html:select onchange="javascript:update('<bean:write
> name='productId'/>)">abc</html:select> and
> <html:button onclick="javascript:update('<bean:write name='productId'/>)"/>
>
> when the I intended the output to be something like
>
> <html:select onchange="javascript:update('5)">abc</html:select> and
> <html:button onclick="javascript:update('5')"/>
>
> Does anyone know why this is happening or am I making a mistake?
>
> Many Thanks
You're making a mistake: what you have is not valid JSP syntax. It is
not legal to use a JSP custom action within an attribute of another
custom action. Instead, use RT expressions or, preferably, JSTL EL:
<html:select onchange="javascript:update('<%=...%>')" ...
<html:select onchange="javascript:update('${...}')" ...
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org