Hi,
I detected a problem with checkbox/radios with dynamic rendered
attribute, that I don't know if it's a JSF or Trinidad bug:
If I have a checkbox with a
rendered="${requestScope.someBooleanAttribute}", and a button that
simple alter that attribute in request, to not render it again. If, at
first step, the component is rendered and I check it, my target value is
setted to true.. But, if I click the button again, the component exists,
and checks if it's value is changed.
For that, we have:
1- wasSubmitted value returns true:
protected boolean wasSubmitted(
FacesContext context,
UIComponent component)
{
FacesBean bean = getFacesBean(component);
return !getDisabled(bean) && !getReadOnly(context, bean);
}
2- getSubmittedValue returns FALSE!
public Object getSubmittedValue(
FacesContext context,
UIComponent component)
{
if (super.getSubmittedValue(context, component) == null)
return Boolean.FALSE;
return Boolean.TRUE;
}
3- The value was changed to FALSE...
It occurs to radio and combos too..
The getSubmittedValue is correctly implemented, because if the checkbox
is unmarked the browser don't send the parameter, and
super.getSubmittedValue(context, component) returns null.
My suggestion is, in that cases, render a hidden field that indicates
that the component was rendered, to check it in wasSubmitted...
Something like:
<input type="hidden" name="form:j_id_jsp_1240287335_0i7_rendered"
value="true">
where form:j_id_jsp_1240287335_0i7 is the component's client id. And:
protected boolean wasSubmitted(
FacesContext context,
UIComponent component)
{
if (!wasRendered(context)) {
return false;
}
FacesBean bean = getFacesBean(component);
return !getDisabled(bean) && !getReadOnly(context, bean);
}
protected boolean wasRendered(...) {
String clientId = component.getClientId(context);
return context.getExternalContext().
getRequestParameterMap().get(clientId+"_rendered")!=null;
}
There are other solution?
Thanks,
Bruno E. Grossi