struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Håkon T Sønderland <>
Subject Re: Conditional Layout - BASIC
Date Mon, 27 Sep 2004 16:46:10 GMT
Freddy Villalba A. wrote:
> Hi everybody,
> I have a lapsus-mentis... it's been a while since I last used Struts and I
> haven't been able to find the answer anywhere around (although it's a pretty
> stupid, straightforward question). Anyway, here it goes...
>>>From a JSP, I want to paint the properties (value) in my actionForm in 2
> different ways (input fields or plain text), depending on whether there is a
> value to paint or not.
> For example:
> Suppose I have an actionForm with a property, invoiceID.
> If that property's value is null / "", I'd like to paint it like this:
> <td>INVOICE ID:</td><td><html:text ... /></td>    (an "text"
input so that
> it can be assigned a value on the form)
> On the other hand, if that property has a value (say "B-NC0001231"), then
> I'd paint it like this:
> <td>INVOICE ID:</td><td>B-NC0001231</td>    (plain text, since
it's not
> editable)

Something like this:

  <logic:empty name="yourForm" property="invoiceID">
    <td>Invoice ID: </td>
    <td><html:text name="yourForm" property="invoiceID"/></td>
  <logic:notEmpty name="yourForm" property="invoiceID">
    <td>Invoice ID:</td>
    <td><bean:write name="yourForm" property="invoiceID"/></td>

provided your form tag is something like this:
  <html:form action="invoice">

and your struts-config.xml has something like this in it:
	    <action path="/invoice"
              etc. etc...>

Hope this helps,
We shall fight on the beaches,
we shall fight on the landing grounds,
we shall fight in the fields and in the streets,
we shall fight in the hills;
we shall never surrender

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message