struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gonzalez, Rafael E" <>
Subject RE: referring to a formBean property in a scriptlet
Date Fri, 24 Aug 2001 15:12:23 GMT
You have access to your formBean in a scriplet since the formBean is
assummed to be created or the framework will create one for you if you
declared properly in the <form-beans> mappings (see user guide section 2.3).
The form bean is created and placed in the session for you to use it. I
highly recommend to use the <logic:equal> and <bean:write> tags to perform
what you want.
for example:

<logic:equal name="yourFormBean" property="isNew" value="true">
  <html:text property="employeeId" size="30" maxlength="30"/>
<logic:equal name="yourFormBean" property="isNew" value="false">
   <bean:write name=yourFormBean" property="employeeeID" filter="true"/>

You need to declare the struts library tags in your jsp page and the proper
<action> and <form-bean> mappings in the struts-config.xml 
I hope this helps.

> -----Original Message-----
> From: Esbrook, Scott []
> Sent: Friday, August 24, 2001 10:58 AM
> To:
> Subject: referring to a formBean property in a scriptlet
> Hello,
> I'm new to Struts, and really like what I see. I didn't see 
> this in the
> docs, so maybe someone can answer this. 
> I'm working on a small sample app that displays an Employee 
> Id on a form for
> maintenance. I need to display the ID as static text if the 
> Employee record
> already exists, or in a textfield if the Employee record does 
> not yet exist.
> So I put a boolean flag 'isNew' in the formBean. What's the 
> best way to
> refer to that flag within a scriptlet? That is, 
> <% if ( ??FORMBEAN??.getIsNew() ) { %>
>    <html:text property="employeeId" size="30" maxlength="30"/>
> <% } else { %>
>    <%= ??FORMBEAN??.getEmployeeId() %>
> <% } %>
> Does Struts provide a standard id I can use to refer to my 
> formBean? Or do I
> have to put in a 'useBean' directive and access the bean directly?
> Thanks,
> Scott Esbrook
> Software Developer
> Compuware Corporation

View raw message