webtier@glassfish.java.net

how do you write a custom UIComponent that accepts a custom attribute type

From: <webtier_at_javadesktop.org>
Date: Thu, 07 Jan 2010 15:08:26 PST

Hi I'm trying to write a custom UIComponent which accepts attributes which are of a non-native type.
I've already written custom UIComponents which use String and ints as attributes but now I want a

i.e. in my Jsf I want to put something like

<foo:renderMyObject myOwnObject="#{myJsfBean.myOwnObject}" />

I already know how to do this for String and int and other built-in primitive types so I'm specifically asking about Custom classes only.

So what I've tried is something like this (which doesn't work) :

public class MyOwnObject
{
}


@ManagedBean
public class MyJsfBean
{
   public MyOwnObject getMyOwnObject() ...
}

@FacesComponent(value="renderMyObject")
public class RenderMyObject extends UIComponentBase
{
        private MyOwnObject myOwnObject=null;

        public void setMyOwnObject(MyOwnObject x) ...
}

In the above example, the getMyOwnObject() is never even called in the JSF Managed Bean, and the setMyOwnObject is never called in the component. I'm thinking there's something special about custom objects which I can't seem to find any documentation about... If I switch the above to String instead of my custom object it all works.

Anyone know how I'm suppose to properly do the above? Thanks.
[Message sent by forum member 'tedman' (tedman_at_sfu.ca)]

http://forums.java.net/jive/thread.jspa?messageID=379456