You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Lking <lk...@yahoo.com.br> on 2005/04/29 16:06:07 UTC
How to set JSF component properties before JSF is loaded?
Hi all,
As a newbie in JSF and MyFaces I'm wondering how to set some component
property before JSF page is loaded.
I have a page with a DataTable and before it's shown I'd like to change
some properties like the columns and based on a criteria I'd like to set the
rendered property of some commandButton as well. There's properties will
always be the same so I set those in the page itself. But others are going
to be changed the first time the page is loaded. I tried the constructor but
it didn't worked out because all components were still "null" and they will
remain until I invoke the first action.
At the moment I only got it changing all my get methods checking... if
(component == null) component = new HtmlDataTable();.. but it doesn't seem
to be what I want because all the properties I set in the page were lost...
Has anyone a way to solve it?
Thanks and sorry for my english,
Lkin.
Re: How to set JSF component properties before JSF is loaded?
Posted by Mike Kienenberger <mk...@gmail.com>.
I'm also a newbie, but I believe you do this as follows:
<h:dataTable id="table"
binding="#{backingBeanClassInstance.dataTable}"
public class BackingBeanClass
{
private HtmlDataTable dataTable;
public HtmlDataTable getRelationshipDataTable()
{
return this.dataTable;
}
public void setDataTable(HtmlDataTable dataTable)
{
this.dataTable= dataTable;
// perform any initialization
// note that this will be called on every request,
// so this initialization may have already run once before.
}
}
I've used this method to dynamically add columns to an empty HtmlDataTable.
On 4/29/05, Lking <lk...@yahoo.com.br> wrote:
> Hi all,
>
> As a newbie in JSF and MyFaces I'm wondering how to set some component
> property before JSF page is loaded.
>
> I have a page with a DataTable and before it's shown I'd like to change
> some properties like the columns and based on a criteria I'd like to set the
> rendered property of some commandButton as well. There's properties will
> always be the same so I set those in the page itself. But others are going
> to be changed the first time the page is loaded. I tried the constructor but
> it didn't worked out because all components were still "null" and they will
> remain until I invoke the first action.
>
> At the moment I only got it changing all my get methods checking... if
> (component == null) component = new HtmlDataTable();.. but it doesn't seem
> to be what I want because all the properties I set in the page were lost...
>
> Has anyone a way to solve it?
>
> Thanks and sorry for my english,
> Lkin.
>
>