struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ted Husted <hus...@apache.org>
Subject Re: referring to a formBean property in a scriptlet
Date Fri, 24 Aug 2001 15:16:59 GMT
You probably want to take a look at the logic tags.  Here's some code
from one of mine that tests whether the key is null. Records with null
keys are new.

<tr> 
<td align="right" nowrap>Article ID:</td>
<logic:notPresent name="articleForm" property="key">
<td align="left">&nbsp;<html:hidden property="key"/><font
color="#CCCCCC"><i>not assigned</i></font></td>
</logic:notPresent>
<logic:present name="articleForm" property="key">
<td align="left">&nbsp;<html:hidden property="key"/><bean:write
name="articleForm" property="key"/></td>
</logic:present>
<td>&nbsp;</td>
</tr>


-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/about/struts/


"Esbrook, Scott" wrote:
> 
> 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

Mime
View raw message