You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ael <al...@dash.com.ph> on 2010/10/19 06:09:18 UTC

T5 Customize Returned List.

Hello everyone i have a List which is returned from a Database. Then i want
to customize its returned value.
Is that possible?



     <t:loop source="Source" value="source" >
          {$source.value}
     </t:loop>



Ex. {$source.value} if value == 1 it will display OK if value == 2 it will
display Cancel.
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Customize-Returned-List-tp3218486p3218486.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: T5 Customize Returned List.

Posted by ael <al...@dash.com.ph>.
Ahhh

Now i understand i can access the source field using getter in the page
class
Therefore i don't need to use property anymore.

I will try it. 

Thanks Everyone.
-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Customize-Returned-List-tp3218486p3218850.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: T5 Customize Returned List.

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, 19 Oct 2010 08:08:07 -0200, ael <al...@dash.com.ph> wrote:

> Sorry i will made it clear.
>
> Page Class
> @Property
> private TableSource sourceA;
>
> public List<TableSource> getSource(){
>      return List<TableSource>;
> }
>
> Template
> <t:loop source="Source" value="sourceA" >
>           {$sourceA.value}
> </t:loop>

public String getValue() {
	if (sourceA.value == 1) {
		return "OK";
	}
	else {
		return "Not OK";
	}
}

<t:loop source="Source" value="sourceA">
	${value}
</t:loop>

What you want is logic and logic belongs to component and page classes,  
not in the template. ;)

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


RE: T5 Customize Returned List.

Posted by ael <al...@dash.com.ph>.
Sorry i will made it clear.

Page Class
@Property
private TableSource sourceA;

public List<TableSource> getSource(){
     return List<TableSource>;
}

Template
<t:loop source="Source" value="sourceA" >
          {$sourceA.value}
</t:loop> 


Something like this... tapestry will automatically loop the item based on
List<TableSource>
But i want to know if it is possible i can customize the value.

Ex. {$sourceA.value} output is "1" then i will make it "OK".


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Customize-Returned-List-tp3218486p3218778.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: T5 Customize Returned List.

Posted by Jim O'Callaghan <jc...@yahoo.co.uk>.
I'm surprised Tapestry didn't complain when you have an annotation @Property
on the item and also a matching explicit getter.  In the .tml I think you
should use distinct naming for the source and value arguments as the
behavior might not be what you expect otherwise (T5 is case insensitive in
this area?).  Why don't you try:


.java
@Property
private TableSource source;
@Property
private List<TableSource> sources;
**no explicit get methods**


.tml
<t:loop source="Sources" value="source" >
          {source.attribute}
</t:loop>

...where attribute is a property with a public getter on the TableSource
class.

Regards,
Jim.

-----Original Message-----
From: ael [mailto:alan-luayon@dash.com.ph] 
Sent: 19 October 2010 10:02
To: users@tapestry.apache.org
Subject: Re: T5 Customize Returned List.


Hello 

Hmm it is returned as a List<TableClass>.


@Property
private TableSource source;


public List<TableClass> getSource(){
     return List<TableClass>;
}

<t:loop source="Source" value="source" >
          {$source.value}
</t:loop> 


That is my problem...


-- 
View this message in context:
http://tapestry.1045711.n5.nabble.com/T5-Customize-Returned-List-tp3218486p3
218709.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


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: T5 Customize Returned List.

Posted by ningdh <ni...@gmail.com>.
Hi,

Don't quiet understand your problem.

Do you mean object type casting? 

----- Original Message ----- 
From: "ael" <al...@dash.com.ph>
To: <us...@tapestry.apache.org>
Sent: Tuesday, October 19, 2010 5:01 PM
Subject: Re: T5 Customize Returned List.


> 
> Hello 
> 
> Hmm it is returned as a List<TableClass>.
> 
> 
> @Property
> private TableSource source;
> 
> 
> public List<TableClass> getSource(){
>     return List<TableClass>;
> }
> 
> <t:loop source="Source" value="source" >
>          {$source.value}
> </t:loop> 
> 
> 
> That is my problem...
> 
> 
> -- 
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Customize-Returned-List-tp3218486p3218709.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: T5 Customize Returned List.

Posted by ael <al...@dash.com.ph>.
Hello 

Hmm it is returned as a List<TableClass>.


@Property
private TableSource source;


public List<TableClass> getSource(){
     return List<TableClass>;
}

<t:loop source="Source" value="source" >
          {$source.value}
</t:loop> 


That is my problem...


-- 
View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Customize-Returned-List-tp3218486p3218709.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: T5 Customize Returned List.

Posted by ningdh <ni...@gmail.com>.
Hi,

Why not do it in Java?

public String getLabel() {
   if (==1) {
    return "OK";
  }
  if (==2) {
    return "Cancel";
  }
}

.tml

${label}

----- Original Message ----- 
From: "ael" <al...@dash.com.ph>
To: <us...@tapestry.apache.org>
Sent: Tuesday, October 19, 2010 12:09 PM
Subject: T5 Customize Returned List.


> 
> Hello everyone i have a List which is returned from a Database. Then i want
> to customize its returned value.
> Is that possible?
> 
> 
> 
>     <t:loop source="Source" value="source" >
>          {$source.value}
>     </t:loop>
> 
> 
> 
> Ex. {$source.value} if value == 1 it will display OK if value == 2 it will
> display Cancel.
> -- 
> View this message in context: http://tapestry.1045711.n5.nabble.com/T5-Customize-Returned-List-tp3218486p3218486.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
> 
>