You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mite <mi...@gmail.com> on 2010/04/08 22:11:43 UTC
Coercion from String to ArrayList in Loop
Hi
I have this method and need to display the strings in the .tml. When the
page is opened the first time it works fine. But when I submit from the page
it throws:
Could not find a coercion from type java.lang.String to type
java.util.ArrayList.
In the documentation is written that this might happen in T5.1:
"You may see type coercion errors on pages where you have specified the
encoder parameter of the Grid, Loop or AjaxFormLoop components as a
PrimaryKeyEncoder" http://tapestry.apache.org/tapestry5.1/upgrade.html here
But I am not using any encoder. And I think that I shouldn't be because
String and ArrayList are not custom types.
<tr t:type="loop" t:source="scheduledCourseEvents"
t:value="currentScheduledEvent">
<td t:type="loop" t:source="currentScheduledEvent"
t:value="scheduledEventCell">
${scheduledEventCell}
</td>
</tr>
@Property
private ArrayList<String> currentScheduledEvent;
@Property
private String scheduledEventCell;
public ArrayList<ArrayList<String>> getScheduledCourseEvents(){
ArrayList<ArrayList<String>> res = new ArrayList<ArrayList<String>>();
for(InstructionEvent insEvent:
eventManager.getInstructionEventsByCourse(currentCourse.getCourseId())){
EventSlot es =
eventManager.getEventSlotForEvent(insEvent.getEvent().getEventId());
if(es != null){
ArrayList<String> temp = new ArrayList<String>();
temp.add(es.getSlot().getDay()+"");
temp.add(es.getSlot().getHour()+" часот");
temp.add(es.getSlot().getFacility().getTitle());
temp.add(insEvent.getInstructionType().getTitle());
res.add(temp);
}
}
return res;
}
Anyone has an idea how can this be solved?
Thank you
--
View this message in context: http://old.nabble.com/Coercion-from-String-to-ArrayList-in-Loop-tp28183967p28183967.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Coercion from String to ArrayList in Loop
Posted by Mite <mi...@gmail.com>.
Thanks, it works now.
--
View this message in context: http://old.nabble.com/Coercion-from-String-to-ArrayList-in-Loop-tp28183967p28190833.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Coercion from String to ArrayList in Loop
Posted by "Juan E. Maya" <ma...@gmail.com>.
Hi,
if you're not editing the objects just set the formState="none" in the Loop
components.
On Thu, Apr 8, 2010 at 10:11 PM, Mite <mi...@gmail.com> wrote:
>
> Hi
>
> I have this method and need to display the strings in the .tml. When the
> page is opened the first time it works fine. But when I submit from the
> page
> it throws:
>
> Could not find a coercion from type java.lang.String to type
> java.util.ArrayList.
>
> In the documentation is written that this might happen in T5.1:
> "You may see type coercion errors on pages where you have specified the
> encoder parameter of the Grid, Loop or AjaxFormLoop components as a
> PrimaryKeyEncoder" http://tapestry.apache.org/tapestry5.1/upgrade.htmlhere
>
> But I am not using any encoder. And I think that I shouldn't be because
> String and ArrayList are not custom types.
>
> <tr t:type="loop" t:source="scheduledCourseEvents"
> t:value="currentScheduledEvent">
> <td t:type="loop" t:source="currentScheduledEvent"
> t:value="scheduledEventCell">
> ${scheduledEventCell}
> </td>
> </tr>
>
> @Property
> private ArrayList<String> currentScheduledEvent;
> @Property
> private String scheduledEventCell;
>
> public ArrayList<ArrayList<String>> getScheduledCourseEvents(){
> ArrayList<ArrayList<String>> res = new
> ArrayList<ArrayList<String>>();
> for(InstructionEvent insEvent:
> eventManager.getInstructionEventsByCourse(currentCourse.getCourseId())){
> EventSlot es =
> eventManager.getEventSlotForEvent(insEvent.getEvent().getEventId());
> if(es != null){
> ArrayList<String> temp = new ArrayList<String>();
> temp.add(es.getSlot().getDay()+"");
> temp.add(es.getSlot().getHour()+" часот");
> temp.add(es.getSlot().getFacility().getTitle());
> temp.add(insEvent.getInstructionType().getTitle());
> res.add(temp);
> }
> }
>
> return res;
> }
>
> Anyone has an idea how can this be solved?
> Thank you
> --
> View this message in context:
> http://old.nabble.com/Coercion-from-String-to-ArrayList-in-Loop-tp28183967p28183967.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>