You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by William Lopes <wi...@gmail.com> on 2012/06/23 23:00:09 UTC
HashMap with Grid (or Loop)
So, I come here to ask how I make to use the HashMap<Long, List<Object>> in
the Grid (or Loop case not be possible in the grid).
I'm trying to do like below:
Page.java
> @Property
private Long currentHashMapKey;
@Persist
private Object object;
> @Persist
private HashMap<Long, List<Object>> hashMap;
public HashMap<Long, List<Object>> getHashMap() {
// commands
}
> public List<Object> getList() {
return hashMap.get(this.currentHashMapKey);
}
> getObject()
setObject()
Page.tml
> <t:Layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
> <head>
> <title>Page</title>
> </head>
> <body>
>
>
> <t:loop t:source="hashMap" t:value="currentHashMapKey">
> <t:loop t:source="list" t:value="object">
> ${object.value}<br/>
> </t:loop>
</t:loop>
> </body>
> </t:Layout>
But, I always receive a error like that:
Render queue error in SetupRender[Page:loop]: Failure reading parameter
'source' of component Page:loop:
org.apache.tapestry5.ioc.internal.util.TapestryException
Thanks a lot.
Re: HashMap with Grid (or Loop)
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Sun, 24 Jun 2012 22:01:41 -0300, William Lopes
<wi...@gmail.com> wrote:
> @Thiago
> Tudo bem sim e você?
Please post in English only in this mailing list.
> Eu coloquei o Object apenas para ficar mais fácil de entender, porque se
> eu colocar os nomes das entidades do português, talvez eles não entendam.
Translating:
> I've only put Object to make it easier to understand because if I put
> the names ofthe entities in Portuguese, maybe they (non-Portuguese
> speakers) wouldn't understand.
I understand, but, in this case, the code you posted isn't equivalent to
the original one and it wouldn't work for a different reason. Tapestry
doesn't use reflection, so trying to use ${xxx.value} in a property of
type Object would cause an exception saying class Object doesn't have an
xxx property. I suggest you, when you're posting another question, to not
change the types. We in the list are used to see code with non-English
words and still understand them. :)
Cheers!
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: HashMap with Grid (or Loop)
Posted by William Lopes <wi...@gmail.com>.
@Lance
You're right.
Thank you, but I solved changing hashMap for a list more elaborate and
works.
@Thiago
Tudo bem sim e você?
Eu coloquei o Object apenas para ficar mais fácil de entender, porque se eu
colocar os nomes das entidades do português, talvez eles não entendam.
Hugs.
2012/6/23 Thiago H de Paula Figueiredo <th...@gmail.com>
> Bão? :)
>
> On Sat, 23 Jun 2012 18:00:09 -0300, William Lopes <
> williamlopes.dev@gmail.com> wrote:
>
> @Persist
> private Object object;
>
>
> <t:loop t:source="list" t:value="object">
> ${object.value}<br/>
> </t:loop>
>
> This (object.value) won't work because your object property is of type
> Object, which doesn't have a property named value.
>
>
> Render queue error in SetupRender[Page:loop]: Failure reading parameter
>> 'source' of component Page:loop:
>> org.apache.tapestry5.ioc.**internal.util.**TapestryException
>>
>
> Please always post the full stack trace from the console or log, otherwise
> we cannot help. We're not Mãe Dinah, hehehe.
>
> Non-requested advice: it seems you're using a Map to structure data. If
> that's the case, don't do that. Write classes to structure your data
> instead. It'll make your life easier in general and with Tapestry too.
>
> --
> Thiago H. de Paula Figueiredo
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: HashMap with Grid (or Loop)
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
Bão? :)
On Sat, 23 Jun 2012 18:00:09 -0300, William Lopes
<wi...@gmail.com> wrote:
@Persist
private Object object;
<t:loop t:source="list" t:value="object">
${object.value}<br/>
</t:loop>
This (object.value) won't work because your object property is of type
Object, which doesn't have a property named value.
> Render queue error in SetupRender[Page:loop]: Failure reading parameter
> 'source' of component Page:loop:
> org.apache.tapestry5.ioc.internal.util.TapestryException
Please always post the full stack trace from the console or log, otherwise
we cannot help. We're not Mãe Dinah, hehehe.
Non-requested advice: it seems you're using a Map to structure data. If
that's the case, don't do that. Write classes to structure your data
instead. It'll make your life easier in general and with Tapestry too.
--
Thiago H. de Paula Figueiredo
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: HashMap with Grid (or Loop)
Posted by Lance Java <la...@googlemail.com>.
The source parameter of loop must either be an array or implement Iterable.
I think you want to use one of map.keySet(), map.values() or map.entrySet()
On Saturday, 23 June 2012, William Lopes <wi...@gmail.com> wrote:
> So, I come here to ask how I make to use the HashMap<Long, List<Object>>
in
> the Grid (or Loop case not be possible in the grid).
>
> I'm trying to do like below:
>
> Page.java
>
>> @Property
>
> private Long currentHashMapKey;
>
>
>
> @Persist
>
> private Object object;
>
>
>> @Persist
>
> private HashMap<Long, List<Object>> hashMap;
>
>
>
> public HashMap<Long, List<Object>> getHashMap() {
>
> // commands
>
> }
>
>
>> public List<Object> getList() {
>
> return hashMap.get(this.currentHashMapKey);
>
> }
>
>
>> getObject()
>
> setObject()
>
>
> Page.tml
>
>> <t:Layout xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
>> <head>
>> <title>Page</title>
>> </head>
>> <body>
>>
>>
>> <t:loop t:source="hashMap" t:value="currentHashMapKey">
>> <t:loop t:source="list" t:value="object">
>> ${object.value}<br/>
>> </t:loop>
>
> </t:loop>
>
>
>> </body>
>> </t:Layout>
>
>
> But, I always receive a error like that:
> Render queue error in SetupRender[Page:loop]: Failure reading parameter
> 'source' of component Page:loop:
> org.apache.tapestry5.ioc.internal.util.TapestryException
>
> Thanks a lot.
>