Would it be possible to develop an own savestate component that'll work with JSF2.3 ?
Yes.
Here's a kickoff example based off the original source code of <t:saveState>
:
@FacesComponent(createTag=true)
public class SaveState extends UIParameter {
public SaveState() {
setRendererType(null);
}
@Override
public Object saveState(FacesContext context) {
Object[] values = new Object[2];
values[0] = super.saveState(context);
if (getValueExpression("value") != null) {
values[1] = getValue();
}
return values;
}
@Override
public void restoreState(FacesContext context, Object state) {
Object values[] = (Object[]) state;
super.restoreState(context, values[0]);
ValueExpression valueExpression = getValueExpression("value");
if (valueExpression != null) {
valueExpression.setValue(context.getELContext(), values[1]);
}
}
}
In order to use it, declare against the predefined XML name space of http://xmlns.jcp.org/jsf/component
:
<anyElement ... xmlns:my="http://xmlns.jcp.org/jsf/component">
...
<my:saveState value="#{bean.property}" />
...
</anyElement>
That's all. Thanks to the createTag=true
feature of the @FacesComponent
you don't need to explicitly register the custom component in any XML file.
An alternative would be to use OmniFaces <o:inputHidden>
, but that would potentially require an explicit converter as it's passed as a HTTP request parameter rather than via JSF state.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…