You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by fergunet <fe...@hotmail.com> on 2007/08/08 14:31:41 UTC

How to list a property in a display:table (Struts 2)

Hi all!

I've created a display table to show a list of things and their attributes.
But one of those attributes is another list of objects. I don't know how to
print their names.

Let's see what I have:


<display:table name="usersBase" class="displaytag" pagesize="10"
defaultsort="1" 
                       defaultorder="ascending" export="true" id="row"
requestURI="/user/list.mpch" >
            <display:caption title="global.users"/>
            <display:column property="id" titleKey="global.id"
sortable="true" headerClass="sortable"/>
            <display:column property="login" titleKey="global.login"
sortable="true" headerClass="sortable"/>
            <display:column property="name" titleKey="global.name"
sortable="true" headerClass="sortable"/>
            <display:column property="cif" titleKey="global.cif"
sortable="true" headerClass="sortable"/>
            <display:column property="email" titleKey="global.email"
sortable="true" headerClass="sortable"/>
            <display:column property="roles" titleKey="global.roles"
sortable="true" headerClass="sortable"/>
            
            <display:column title="Roles">
                <s:iterator value="${row.roles}">
                    ITERATE!!!!
                </s:iterator>
                
                
            </display:column>
            <display:column title="getTextglobal.provider" sortable="true"
headerClass="sortable">
                <s:if test="${row.provider}==true">
                    Is provider                    
                </s:if>
                <s:else>
                    Is not provider
                </s:else>
</display:table>


Look at the "roles" property column. That property is a List<RoleVO> which
have an attribute RoleBaseVO wich have the String "name". I'm trying to show
the list of that names. (Now only prints:
[org.myapp.common.isc.model.users.RoleVO@d53d82,
org.myapp.common.isc.model.users.RoleVO@1b939d3,
org.myapp.common.isc.model.users.RoleVO@1836525] )

I thought to use an iterator as you can see, but the "ITERATE!!!" string is
never shown.

Any ideas? Thanks in advance, and sorry about my English.
-- 
View this message in context: http://www.nabble.com/How-to-list-a-property-in-a-display%3Atable-%28Struts-2%29-tf4236011.html#a12052184
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to list a property in a display:table (Struts 2)

Posted by fergunet <fe...@hotmail.com>.
Thank you Toni! It worked!

Only adding 
<display:column titleKey="global.roles">
                
                <s:iterator value="#attr.row.roles"> 
                    <s:property value="roleBaseVO.name" />
                    
                </s:iterator>


and all is shown ok.

Thank you again ;)


Toni Lyytikäinen wrote:
> 
> Set the uid attribute in the display:table -tag like this:
> 
> <display:table uid="row" name="..." id="..." ...
> 
> after that you can refer to the row from struts tags by using #attr.row
> 
> so the iterator should now works like this:
> 
> <s:iterator value="#attr.row.roles">
> 
> On 8/8/07, fergunet <fe...@hotmail.com> wrote:
>>
>>
>> Hi all!
>>
>> I've created a display table to show a list of things and their
>> attributes.
>> But one of those attributes is another list of objects. I don't know how
>> to
>> print their names.
>>
>> Let's see what I have:
>>
>>
>> <display:table name="usersBase" class="displaytag" pagesize="10"
>> defaultsort="1"
>>                        defaultorder="ascending" export="true" id="row"
>> requestURI="/user/list.mpch" >
>>             <display:caption title="global.users"/>
>>             <display:column property="id" titleKey="global.id"
>> sortable="true" headerClass="sortable"/>
>>             <display:column property="login" titleKey="global.login"
>> sortable="true" headerClass="sortable"/>
>>             <display:column property="name" titleKey="global.name"
>> sortable="true" headerClass="sortable"/>
>>             <display:column property="cif" titleKey="global.cif"
>> sortable="true" headerClass="sortable"/>
>>             <display:column property="email" titleKey="global.email"
>> sortable="true" headerClass="sortable"/>
>>             <display:column property="roles" titleKey="global.roles"
>> sortable="true" headerClass="sortable"/>
>>
>>             <display:column title="Roles">
>>                 <s:iterator value="${row.roles}">
>>                     ITERATE!!!!
>>                 </s:iterator>
>>
>>
>>             </display:column>
>>             <display:column title="getTextglobal.provider"
>> sortable="true"
>> headerClass="sortable">
>>                 <s:if test="${row.provider}==true">
>>                     Is provider
>>                 </s:if>
>>                 <s:else>
>>                     Is not provider
>>                 </s:else>
>> </display:table>
>>
>>
>> Look at the "roles" property column. That property is a List<RoleVO>
>> which
>> have an attribute RoleBaseVO wich have the String "name". I'm trying to
>> show
>> the list of that names. (Now only prints:
>> [org.myapp.common.isc.model.users.RoleVO@d53d82,
>> org.myapp.common.isc.model.users.RoleVO@1b939d3,
>> org.myapp.common.isc.model.users.RoleVO@1836525] )
>>
>> I thought to use an iterator as you can see, but the "ITERATE!!!" string
>> is
>> never shown.
>>
>> Any ideas? Thanks in advance, and sorry about my English.
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-list-a-property-in-a-display%3Atable-%28Struts-2%29-tf4236011.html#a12052184
>> Sent from the Struts - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-list-a-property-in-a-display%3Atable-%28Struts-2%29-tf4236011.html#a12066999
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: How to list a property in a display:table (Struts 2)

Posted by Toni Lyytikäinen <to...@gmail.com>.
Set the uid attribute in the display:table -tag like this:

<display:table uid="row" name="..." id="..." ...

after that you can refer to the row from struts tags by using #attr.row

so the iterator should now works like this:

<s:iterator value="#attr.row.roles">

On 8/8/07, fergunet <fe...@hotmail.com> wrote:
>
>
> Hi all!
>
> I've created a display table to show a list of things and their
> attributes.
> But one of those attributes is another list of objects. I don't know how
> to
> print their names.
>
> Let's see what I have:
>
>
> <display:table name="usersBase" class="displaytag" pagesize="10"
> defaultsort="1"
>                        defaultorder="ascending" export="true" id="row"
> requestURI="/user/list.mpch" >
>             <display:caption title="global.users"/>
>             <display:column property="id" titleKey="global.id"
> sortable="true" headerClass="sortable"/>
>             <display:column property="login" titleKey="global.login"
> sortable="true" headerClass="sortable"/>
>             <display:column property="name" titleKey="global.name"
> sortable="true" headerClass="sortable"/>
>             <display:column property="cif" titleKey="global.cif"
> sortable="true" headerClass="sortable"/>
>             <display:column property="email" titleKey="global.email"
> sortable="true" headerClass="sortable"/>
>             <display:column property="roles" titleKey="global.roles"
> sortable="true" headerClass="sortable"/>
>
>             <display:column title="Roles">
>                 <s:iterator value="${row.roles}">
>                     ITERATE!!!!
>                 </s:iterator>
>
>
>             </display:column>
>             <display:column title="getTextglobal.provider" sortable="true"
> headerClass="sortable">
>                 <s:if test="${row.provider}==true">
>                     Is provider
>                 </s:if>
>                 <s:else>
>                     Is not provider
>                 </s:else>
> </display:table>
>
>
> Look at the "roles" property column. That property is a List<RoleVO> which
> have an attribute RoleBaseVO wich have the String "name". I'm trying to
> show
> the list of that names. (Now only prints:
> [org.myapp.common.isc.model.users.RoleVO@d53d82,
> org.myapp.common.isc.model.users.RoleVO@1b939d3,
> org.myapp.common.isc.model.users.RoleVO@1836525] )
>
> I thought to use an iterator as you can see, but the "ITERATE!!!" string
> is
> never shown.
>
> Any ideas? Thanks in advance, and sorry about my English.
> --
> View this message in context:
> http://www.nabble.com/How-to-list-a-property-in-a-display%3Atable-%28Struts-2%29-tf4236011.html#a12052184
> Sent from the Struts - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>