struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Angelo zerr" <>
Subject Re: Easier/simplier way to do read-only versions of pages?
Date Fri, 14 Sep 2007 21:44:46 GMT
You could use Formview Taglib. See at
With Formview you can  manage any fields mode (READONLY, READWRITE,
on server side. With Formview you must not use javascript or not use a lot
of logic:equal.

For instance of you have JSP, like this :

    <!-- HTML input text -->
    <input type="text" name="project" value="Struts Project" />
    <!-- Struts HTML input text -->
    <html:text property="projectDate" />
     .... other JSP taglib....

You set READ state on server side with WEBFormViewUtil class (see documentation)
and after HTML generated is :

    <!-- HTML input text -->
    <input type="text" name="project" value="Struts Project"
    <!-- Struts HTML input text -->
    <input type="text" name="projectDate" value="" readonly="readonly"/>

With Formview you can mange
* role (display field switch
* errors (to set the brakground
color of field with red color).

With Formview you manage any state (CREATE, UPDATE..) and any mode
You choose the HTML generated that you want switch state ans mode and HTML
element type (select, input...)
See at

Regards Angelo

2007/9/14, Geoffrey Gallaway <>:
> Hello,
> I've been looking for a solution that allows me to create form and
> read-only versions of the same page. Each page will have a version
> where a logged-in user can enter the data and a version where a non
> logged in user will only be able to view the data. This is my current
> solution:
> <logic:equal name="readOnly" value="true">
>      <bean:write name="myFormBean" property="firstName"/>
> </logic:equal>
> <logic:equal name="readOnly" value="false">
>      <html:text property="firstName" maxlength="100"
> styleClass="textInput"/>
> </logic:equal>
> That's 6 lines of code for what only needs to be 1 or 2 lines of
> code. It would be 8 lines if I wrapped it in a logic:present tag to
> prevent errors if readOnly doesn't get set in the action.
> I've received suggestions such as "just set the field to read-only or
> disabled" but I don't want the user to see the form-elements. I've
> also been told to use javascript and spin through each field on page
> load. I don't like relying on javascript for this kind of problem.
> I've considered extending the standard struts html taglib to allow
> for a "editMode" tag but if someone has already come up with a good
> solution I'd like to hear about it.
> Thanks,
> Geoffeg
> ---------------------------------------------------------------------
> To unsubscribe, e-mail:
> For additional commands, e-mail:

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