Hi
 
You should look at Clay in the Shale project. This is a piece of cake using 
symbols in Clay.
 
Hermod

-----Original Message-----
From: Rønnevik, Eivind [mailto:[EMAIL PROTECTED]
Sent: Thursday, May 31, 2007 2:24 PM
To: MyFaces Discussion
Subject: Change valueBinding of t:dataTable based on condition



Hi!

 

I was just curious, is there any way I can change the value of a dataTable 
based on different conditions?

 

I'll try to give a simple example to explain what I want. :)

 

Let's say I use the graphicImage tag, in the value property I could either 
write the path to the image

<t:graphicImage value="/images/myImage.gif"

Or I can use an expression that returns a String pointing to the image

<t:graphicImage value#{myBean.pathToImage}"

 

I have the need of using the same jsp twice, but based on a boolean property 
the datasource for the dataTable on this page would differ.

 

Theoretically, this way of setting the value-property would represent what I 
would want to do:

 

<t:dataTable value="#{myBean.boolean ? '#{oneBean.dataModel}' : '#{ 
anotherBean.dataModel}'}"

 

This would work if the value property expected a String, but instead it expects 
an expression that directly points to a collection of some sort.

 

I also tried to point to a method in my bean that returns the correct 
value-string based on the Boolean:

 

<t:dataTable value="#{myBean.tableValue

 

where the getTableValue-method is like this:

 

public String getTableValue()

{

            if(condition)

                  return "#{oneBean.dataModel}";

            return "#{anotherBean.dataModel}";

            

}

 

But of course this fails since the dataTable expects a collection and not a 
String.

 

 

 

I know that I in my getTableValue-method can return the proper collection:

 

public DataModel getTableValue()

{

            if(condition)

                  return getOneBean().getDataModel();

            return getAnotherBean().getDataModel();

            

}

 

but then I would have to set the references to these other beans, and I can't 
do that because it would cause a cyclic reference.. 

 

So, are there other solutions to this or do I have to rethink my way of doing 
this? :)

 

Regards,

 

Eivind

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

This email with attachments is solely for the use of the individual or
entity to whom it is addressed. Please also be aware that the DnB NOR Group
cannot accept any payment orders or other legally binding correspondence with
customers as a part of an email. 

This email message has been virus checked by the anti virus programs used
in the DnB NOR Group.

* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

Reply via email to