struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Puneet Lakhina" <puneet.lakh...@gmail.com>
Subject Re: setting an an html:text value with another html:text
Date Tue, 14 Nov 2006 18:37:09 GMT
On 11/14/06, Adam K <adamk1@gmail.com> wrote:
>
> Hi all , I am attempting to do the following, and it obviously isn't
> working, but I was hoping someone on the list would point me to something
> that might work instead:
>
> I have this text field and I want to be able to alternate the readonly
> property from true and false.  I tried to put in the below which is bolded
>
>                         <html:text name="OrderForm" property="shipTo"
> readonly="WANTTOTOGGLE"  ></html:text>
>
>
>                         <html:text name="OrderForm" property="shipTo"
> readonly="<html:text name="OrderForm" property="readonly"></html:text>"
> ></html:text>
>
> Any thoughts or ideas as to how I could do that in a nice manner would be
> greatly appreciated.
>
> What is going to happen is that the action is going to toggle the value
> depending on a parameter comming in from the URL.


so supposing your url has something like this
http://foo.com/bar.do?editable=true

Then you could have in your JSP
<logic:present parameter="editable">
<logic:equal parameter="editable" value="true">
<bean:define id="isReadOnly" scope="page">false</bean:define>
</logic:equal>
<logic:notEqual>
<bean:define id="isReadOnly" scope="page">true</bean:define>
</logic:notEqual>
</logic:present>
<logic:notPresent parameter="editable">
<bean:define id="isReadOnly" scope="page">true</bean:define>
</logic:notPresent>

So now your text box would have

<html:text property="foo" readonly='<%=new
Boolean(pageContext.getAttribute("isReadOnly").toString()).booleanValue()%>'
/>

I know this is unclean but just doing bean write instead of the scriptlet
thing didnt work for me. You could probably clean up the logic tags also.
But i havent ever done JSTL so...


thanks in advance for any thoughts or ideas.
>
>

Hope it helps
-- 
Puneet

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message