struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Angelo zerr" <angelo.z...@gmail.com>
Subject Re: Easier/simplier way to do read-only versions of pages?
Date Fri, 14 Sep 2007 21:44:46 GMT
Hi,
You could use Formview Taglib. See at http://formview.sourceforge.net/
With Formview you can  manage any fields mode (READONLY, READWRITE,
INVISIBLE...)
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 :

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

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"
readonly="readonly"/>
    <!-- Struts HTML input text -->
    <input type="text" name="projectDate" value="" readonly="readonly"/>
    ....

With Formview you can mange
* role http://formview.sourceforge.net/roles.html (display field switch
role)
* errors http://formview.sourceforge.net/errors.html (to set the brakground
color of field with red color).

With Formview you manage any state (CREATE, UPDATE..) and any mode
(READONLY...).
You choose the HTML generated that you want switch state ans mode and HTML
element type (select, input...)
See at http://formview.sourceforge.net/developer-guide.html

Regards Angelo



2007/9/14, Geoffrey Gallaway <geoffeg@geoffeg.org>:
>
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

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