• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Disabling html:text in Struts dynamically

 
Yevgeniy Treyvus
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I disable a text field based on a bean property in Struts ?
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way I know that works is through a JSP scriptlet that evaluates to a boolean as in:

<html:text property="myProperty" disabled='<%=myJavaExpression.isdisabled() %>' />
 
Yevgeniy Treyvus
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried that, but I get the following error:

/WEB-INF/tiles/websm/carrier/info.jsp(23,32) According to TLD or attribute directive in tag file, attribute value does not accept any expressions

But looking at the TLD itself, it says RTexpr is true.

Any ideas?
 
Damanjit Kaur
Ranch Hand
Posts: 346
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
RTexpr is true means- the value for attribute disabled has to be "true".

<html:text property="myProperty" disabled="true" />
 
Yevgeniy Treyvus
Ranch Hand
Posts: 48
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought it meant that it took RT expression as values for arguments used by the tag (i.e) disabled="$(user.readOnly}". Is that not correct ?
[ May 05, 2005: Message edited by: Yevgeniy Treyvus ]
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Struts 1.1 or above? I just ran a test (I'm using WebSphere V5.1) and this works for both a true and a false value.

Here's my code:

Action class:


jsp:


Try posting the code in your jsp, and maybe we can see what the problem is.
 
Ganesh Gowtham
Ranch Hand
Posts: 225
IBM DB2 Eclipse IDE Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in <html:html> we have style attribute if suppose ur html property name "text1" we can give style="display:none" to make this filed visible style="display:inline"

if not just use expression <%= onj.canFieldVisible() %> ang assign to style attribute of input tag...

Gowtham G R
gowtham@eprosoft.com
grgowtham_cse@yahoo.com
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic