struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Håkon T Sønderland <...@antares.no>
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:empty>
  <logic:notEmpty name="yourForm" property="invoiceID">
    <td>Invoice ID:</td>
    <td><bean:write name="yourForm" property="invoiceID"/></td>
  </logic:notEmpty>

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"
              type="...."
	     name="yourForm"
              etc. etc...>


Hope this helps,
Håkon
-- 
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message