>From: "Robert Campbell" <[EMAIL PROTECTED]>
>Hello,
>
>I have a custom component - a class extending UIComponentTag, a class
>Hello,
>
>I have a custom component - a class extending UIComponentTag, a class
>extending UIComponentBase, and a class extending Renderer. The entire
>control works as it should, that is until I hit refresh. Upon a refresh, my
>UIComponentBase class getter functions suddenly return nulls. For instance, my
>tag can look like this:
>
><myapp:sometag myatt="somevalue"></myapp:sometag>
>
>And when the page containing this is first loaded, in my renderer I have:
>
>String someValue = ((UIPermissions) component).getSomeValue();
>
>This works flawlessly the first time the page loads, but getSomeValue() returns
>
><myapp:sometag myatt="somevalue"></myapp:sometag>
>
>And when the page containing this is first loaded, in my renderer I have:
>
>String someValue = ((UIPermissions) component).getSomeValue();
>
>This works flawlessly the first time the page loads, but getSomeValue() returns
>null upon refresh. Any ideas? Thanks everyone... code is listed below.
>
>
Sounds like you need to implement the saveState and restoreState in your
component so that when the view is restored, the components state is also
restored.
[snippet]
>
> public class UIPermissions extends UIComponentBase {
> protected final Log log = LogFactory.getLog(UIPermissions.class);
>
> public static final String COMPONENT_FAMILY = "UIPermissions";
>
> private String sectionName;
>
> public UIPermissions() {
> super();
> }
>
> public String getFamily() {
> return COMPONENT_FAMILY;
> }
>
> public String getSectionName() {
> return sectionName;
> }
>
> public void setSectionName(String sectionNa me) {< BR>> this.sectionName = sectionName;
> }
public Object saveState(FacesContext facescontext) {
Object aobj[] = new Object[2];
aobj[0] = super.saveState(facescontext);
aobj[1] = sectionName;
Object aobj[] = new Object[2];
aobj[0] = super.saveState(facescontext);
aobj[1] = sectionName;
return aobj;
}
}
public void restoreState(FacesContext facescontext, Object obj) {
Object[] sobj = (Object[]) obj;
super.restoreState(facescontext, sobj[0]);
sectionName = (String) sobj[1];
}
Object[] sobj = (Object[]) obj;
super.restoreState(facescontext, sobj[0]);
sectionName = (String) sobj[1];
}
>}
>
[Snippet]