You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Murray Collingwood <mu...@focus-computing.com.au> on 2005/10/17 14:41:07 UTC

Clever trick required

Hi all

Bean 1 has a property, a list of Bean 2s.

I want to display these on the screen but I don't want to display repeated occurrences of 
the same value from Bean 1.  For example, lets assume Bean 1 is surname and Bean 2 
is first names, and we have families, and what I want is something like:

Smith		Tom
    Mary
    Freddy
Jones		John
    Liz
    Jim
    Wendy

What I get is:

Smith		Tom
Smith		Mary
Smith		Freddy
Jones		John
Jones		Liz
Jones		Jim
Jones		Wendy

My code is simple:

<logic:notEmpty name="family">
<logic:iterate name="family" type="Family" id="aFamily">
   <logic:notEmpty name="aFamily" property="members">
   <logic:iterate name="aFamily" property="members" type="Member" id="aMember">
      <tr>
        <td>
           <p>
             <jsp:getProperty name="aFamily" property="name"/>
           </p>
        </td>
        <td>
           <p>
             <jsp:getProperty name="aMember" property="name"/>
           </p>
        </td>
      </tr>
   </logic:iterate>
   </logic:notEmpty> 
</logic:iterate>
</logic:notEmpty>

How do I change this to achieve what I want????  There must be a simple trick for 
doing this.

Kind regards
mc



FOCUS Computing
Mob: 0415 24 26 24
murray@focus-computing.com.au
http://www.focus-computing.com.au



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.1/136 - Release Date: 15/10/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Clever trick required

Posted by Vic Cekvenich <ne...@roomity.com>.
displaytag does it, and it's in sample screens on sf.net.
displaytag should be included in struts!
Also... using logic tag is deprecated. use jstl instead.

.V


Murray Collingwood wrote:
> Hi all
> 
> Bean 1 has a property, a list of Bean 2s.
> 
> I want to display these on the screen but I don't want to display repeated occurrences of 
> the same value from Bean 1.  For example, lets assume Bean 1 is surname and Bean 2 
> is first names, and we have families, and what I want is something like:
> 
> Smith		Tom
>     Mary
>     Freddy
> Jones		John
>     Liz
>     Jim
>     Wendy
> 
>
> 


-- 
thx,
.V

Your Roomity Broadband Community <http://roomity.com/demo.jsp>

cell: 917 825 3035 in DFW
email: netsql at roomity.com


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Clever trick required

Posted by Murray Collingwood <mu...@focus-computing.com.au>.
Thanks Tamas - exactly what I was after!

Kind regards
mc

On 17 Oct 2005 at 21:04, Tamas Szabo wrote:

> Hi mate :-),
> 
> using the indexId property in the second logic:iterate and displaying
> <jsp:getProperty name="aFamily" property="name"/>
> only if indexId is 0 would do waht you want?
> 
> 
> Tamas
> 
> 
> On 10/17/05, Murray Collingwood <mu...@focus-computing.com.au> wrote:
> >
> > Hi all
> >
> > Bean 1 has a property, a list of Bean 2s.
> >
> > I want to display these on the screen but I don't want to display repeated
> > occurrences of
> > the same value from Bean 1. For example, lets assume Bean 1 is surname and
> > Bean 2
> > is first names, and we have families, and what I want is something like:
> >
> > Smith Tom
> > Mary
> > Freddy
> > Jones John
> > Liz
> > Jim
> > Wendy
> >
> > What I get is:
> >
> > Smith Tom
> > Smith Mary
> > Smith Freddy
> > Jones John
> > Jones Liz
> > Jones Jim
> > Jones Wendy
> >
> > My code is simple:
> >
> > <logic:notEmpty name="family">
> > <logic:iterate name="family" type="Family" id="aFamily">
> > <logic:notEmpty name="aFamily" property="members">
> > <logic:iterate name="aFamily" property="members" type="Member"
> > id="aMember">
> > <tr>
> > <td>
> > <p>
> > <jsp:getProperty name="aFamily" property="name"/>
> > </p>
> > </td>
> > <td>
> > <p>
> > <jsp:getProperty name="aMember" property="name"/>
> > </p>
> > </td>
> > </tr>
> > </logic:iterate>
> > </logic:notEmpty>
> > </logic:iterate>
> > </logic:notEmpty>
> >
> > How do I change this to achieve what I want???? There must be a simple
> > trick for
> > doing this.
> >
> > Kind regards
> > mc
> >
> >
> >
> > FOCUS Computing
> > Mob: 0415 24 26 24
> > murray@focus-computing.com.au
> > http://www.focus-computing.com.au
> >
> >
> >
> > --
> > No virus found in this outgoing message.
> > Checked by AVG Anti-Virus.
> > Version: 7.0.344 / Virus Database: 267.12.1/136 - Release Date: 15/10/2005
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
> >
> 



FOCUS Computing
Mob: 0415 24 26 24
murray@focus-computing.com.au
http://www.focus-computing.com.au



-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.344 / Virus Database: 267.12.1/136 - Release Date: 15/10/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Clever trick required

Posted by Tamas Szabo <sz...@gmail.com>.
Hi mate :-),

using the indexId property in the second logic:iterate and displaying
<jsp:getProperty name="aFamily" property="name"/>
only if indexId is 0 would do waht you want?


Tamas


On 10/17/05, Murray Collingwood <mu...@focus-computing.com.au> wrote:
>
> Hi all
>
> Bean 1 has a property, a list of Bean 2s.
>
> I want to display these on the screen but I don't want to display repeated
> occurrences of
> the same value from Bean 1. For example, lets assume Bean 1 is surname and
> Bean 2
> is first names, and we have families, and what I want is something like:
>
> Smith Tom
> Mary
> Freddy
> Jones John
> Liz
> Jim
> Wendy
>
> What I get is:
>
> Smith Tom
> Smith Mary
> Smith Freddy
> Jones John
> Jones Liz
> Jones Jim
> Jones Wendy
>
> My code is simple:
>
> <logic:notEmpty name="family">
> <logic:iterate name="family" type="Family" id="aFamily">
> <logic:notEmpty name="aFamily" property="members">
> <logic:iterate name="aFamily" property="members" type="Member"
> id="aMember">
> <tr>
> <td>
> <p>
> <jsp:getProperty name="aFamily" property="name"/>
> </p>
> </td>
> <td>
> <p>
> <jsp:getProperty name="aMember" property="name"/>
> </p>
> </td>
> </tr>
> </logic:iterate>
> </logic:notEmpty>
> </logic:iterate>
> </logic:notEmpty>
>
> How do I change this to achieve what I want???? There must be a simple
> trick for
> doing this.
>
> Kind regards
> mc
>
>
>
> FOCUS Computing
> Mob: 0415 24 26 24
> murray@focus-computing.com.au
> http://www.focus-computing.com.au
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.12.1/136 - Release Date: 15/10/2005
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
>

Re: Clever trick required

Posted by Aldo Vadillo Batista <al...@gmail.com>.
A possible solution could be:
 <logic:notEmpty name="family">
<logic:iterate name="family" type="Family" id="aFamily">
<logic:notEmpty name="aFamily" property="members">
<bean:define id="firstRow" value="true" />
<logic:iterate name="aFamily" property="members" type="Member" id="aMember">
<logic:notEqual name="firstRow" value="true">
<tr>
<td>
<p>
<jsp:getProperty name="aMember" property="name"/>
</p>
</td>
<td>
<p>&nbsp;</p>
</td>
</tr>
</logic:notEqual>
<logic:equal name="firstRow" value="true">
<tr>
<td>
<p>
<jsp:getProperty name="aFamily" property="name"/>
</p>
</td>
<td>
<p>
<jsp:getProperty name="aMember" property="name"/>
</p>
</td>
</tr>
<bean:define id="firstRow" value="false" />
</logic:equal>
</logic:iterate>
</logic:notEmpty>
</logic:iterate>
</logic:notEmpty>

 2005/10/17, Murray Collingwood <mu...@focus-computing.com.au>:
>
> Hi all
>
> Bean 1 has a property, a list of Bean 2s.
>
> I want to display these on the screen but I don't want to display repeated
> occurrences of
> the same value from Bean 1. For example, lets assume Bean 1 is surname and
> Bean 2
> is first names, and we have families, and what I want is something like:
>
> Smith Tom
> Mary
> Freddy
> Jones John
> Liz
> Jim
> Wendy
>
> What I get is:
>
> Smith Tom
> Smith Mary
> Smith Freddy
> Jones John
> Jones Liz
> Jones Jim
> Jones Wendy
>
> My code is simple:
>
> <logic:notEmpty name="family">
> <logic:iterate name="family" type="Family" id="aFamily">
> <logic:notEmpty name="aFamily" property="members">
> <logic:iterate name="aFamily" property="members" type="Member"
> id="aMember">
> <tr>
> <td>
> <p>
> <jsp:getProperty name="aFamily" property="name"/>
> </p>
> </td>
> <td>
> <p>
> <jsp:getProperty name="aMember" property="name"/>
> </p>
> </td>
> </tr>
> </logic:iterate>
> </logic:notEmpty>
> </logic:iterate>
> </logic:notEmpty>
>
> How do I change this to achieve what I want???? There must be a simple
> trick for
> doing this.
>
> Kind regards
> mc
>
>
>
> FOCUS Computing
> Mob: 0415 24 26 24
> murray@focus-computing.com.au
> http://www.focus-computing.com.au
>
>
>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.344 / Virus Database: 267.12.1/136 - Release Date: 15/10/2005
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>