ActionListener, restoreState issue

Hello,

I have a commandbutton with an actionListener tag set,

in the method that is invoked within the actionListener, I am trying to restore some other ui components on the view as follows:

UIViewRoot viewRoot = FacesContext.getCurrentInstance().getViewRoot();

UIComponent comp = viewRoot.findComponent("someId");

//do something with that component,

the problem is that several variables of that component are not accessible, this is due to the fact that I store them within the component by the saveState method.

I guess that these component properties are not accessible due to the fact that the component's restoreState must be invoked first.

So my question is - where is the right place to restore its state?

and am I right? the actionListener is being invoked -before- the restore state phase ?

thanks,

Asaf.

[888 byte] By [Troubya] at [2007-11-27 10:50:42]
# 1

No the Restore View phase is the first phase of the JSF life cycle.

RaymondDeCampoa at 2007-7-29 11:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Yap,

It is my mistake,

well, my situation is a little bit more complex,

I have a component that extends HtmlPanelGrid (lets name it 'X')

in its encodeBegin method, I add some childs, one of them is an 'HtmlInput' component.

when the form gets rendered, I modify the child's input component, I am not sure how it works, but probably the value is stored automatically, probably the HtmlInput component take care of storing the specified value in form,

then I have two problems:

1) When I invoke the action via the ActionListener and get the 'X' component, The children of this component are not available, I get zero children.

2) When storing the X component's variables via 'saveState' method, I'm trying to fetch the new value of the child's 'HtmlInput' that was specified via the FORM, but I assume this value is not yet accessible in this phase,

so how exactly can I access the new stored value of that child component?

As always,

Many thanks,

Asaf.

Troubya at 2007-7-29 11:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3

look it below ;perhaps it can help you

public void decode(FacesContext facesContext, UIComponent component)

{

RendererUtils.checkParamValidity(facesContext, component, HtmlInputCalendar.class);

String helperString = getHelperString(component);

if (!(component instanceof EditableValueHolder)) {

throw new IllegalArgumentException("Component "

+ component.getClientId(facesContext)

+ " is not an EditableValueHolder");

}

Map paramMap = facesContext.getExternalContext()

.getRequestParameterMap();

String clientId = component.getClientId(facesContext);

if(HtmlRendererUtils.isDisabledOrReadOnly(component))

return;

if(paramMap.containsKey(clientId))

{

String value = (String) paramMap

.get(clientId);

if(!value.equalsIgnoreCase(helperString))

{

((EditableValueHolder) component).setSubmittedValue(value);

}

else

{

((EditableValueHolder) component).setSubmittedValue("");

}

}

else

{

log.warn(

"There should always be a submitted value for an input if it"

+ " is rendered, its form is submitted, and it is not disabled"

+ " or read-only. Component : "+

RendererUtils.getPathToComponent(component));

}

}

in belove code ,the value is from your component from page

and it is before setSubmittedValue()

it is page value ,is not locale value ?

lysmarta at 2007-7-29 11:26:51 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...