Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

html:text

 
Vivek Jaiswal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to use the disabled and readonly attribute of the html:text tag like this:-
<html:text property="something" readonly="<%=flag%>"/>

where "flag" is a String variable passed on to the jsp from the action class through request and can have values "true" or "false"
but i am gettin errors.....y cant i do it this way???
 
Vani Bandargal
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this.
"<%=request.getParameter('flag'%>"/>
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tell us the specific error you're getting. How did you define the "flag" variable?
 
Vivek Jaiswal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Merrill Higginson:
Tell us the specific error you're getting. How did you define the "flag" variable?


in action class:
request.setAttribute("DisplayFlag","true");



in jsp:

<%
String strWard=(String)request.getAttribute("WardNumber");
String dispFlag=(String)request.getAttribute("DisplayFlag");

%>


and this is how i am using it:

<html:text property="tinNumber" size="14" readonly="<%=dispFlag%>"/>


the error m gettin is:

[ServletException in:/Admin/ProcessDealer.jsp] Unable to compile class for JSP An error occurred at line: 64 in the jsp file: /Admin/ProcessDealer.jsp Generated servlet error: D:\NewWorkspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\work\Catalina\localhost\vatweb\org\apache\jsp\Admin\ProcessDealer_jsp.java:223: setReadonly(boolean) in org.apache.struts.taglib.html.BaseHandlerTag cannot be applied to (java.lang.String) _jspx_th_html_text_1.setReadonly(dispFlag);
 
Merrill Higginson
Ranch Hand
Posts: 4864
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The <html:text> tag library is designed to accept a boolean in the readonly property, not a String. So, change your action code to:

request.setAttribute("DisplayFlag", new Boolean(true));

and in your JSP:

boolean dispFlag=((Boolean)request.getAttribute("DisplayFlag")).booleanValue();
 
Vivek Jaiswal
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Merrill Higginson:
The <html:text> tag library is designed to accept a boolean in the readonly property, not a String. So, change your action code to:

request.setAttribute("DisplayFlag", new Boolean(true));

and in your JSP:

boolean dispFlag=((Boolean)request.getAttribute("DisplayFlag")).booleanValue();


thanx merril id worked!!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic