Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a html-tag property dynamically 2

Status
Not open for further replies.

filex

Programmer
Sep 15, 2004
3
0
0
DE
I want to set the html:text-disabled-property dynamically
like this:
Code:
<% boolean disabled = true; %>
<html:form action="/myAction" method="post">
   <html:text property="username" disabled="<%=disabled%>"/>
</html:form>
this works fine .. but I need to define the disabled attribute by either a bean or a pageContext-attribute like
this:
Code:
<% pageContext.setAttribute("disabled", "true"); %>	
<bean:define id="disabled" value="true"/>

I know how to display it on it's own:
Code:
<bean:write name="disabled"/>  
<%= pageContext.getAttribute("disabled") %>

I just don't get it working to read it out into the html:text-element again, because this doesn't work anymore.
Code:
<html:text property="username" disabled="<%=disabled%>"/>


Thank's a lot for your help
 
how about this:

assuming attribute "disabled" has already been set.

Code:
<html:text property="username" disabled="<%= pageContext.getAttribute("disabled") %>"/>

 
I've allready tried, but unfortunatelly it does not work.
Also the following doesn't work:
Code:
<bean:define id="disabled" value="true"/> 
<html:form action="/myAction" method="post">
   <html:text property="username" disabled="<%=disabled%>"/>
</html:form>

I've searched the web, but haven't seen anything like that.
It seems not possible at all. Or do you have another hint for me?

Thanks
 
I tested it, the following works

Code:
<bean:define id="disabled" value="true"/>
<html:form action="/myAction" method="post">
   <html:text property="username" disabled="<%= Boolean.valueOf((String)pageContext.getAttribute("disabled")).booleanValue() %>"/>
</html:form>

a
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top