Extending CDK example for additional input value
icampista Mar 3, 2009 11:14 AMHi RichFaces experts :)
I trying to understand what to do to get an additional attribute that could be binded to a managed bean property.
The target attribute is valueTime, as seen below:
<rf:inputDate value="${mybean.date}" valueTime="${mybean.time}">
Following the CDK example:
http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/cdkguide/en/html_single/index.html#rendererbase
FACELET: I declare the inputDate with extra attribute that needs binding. The AJAX should update the outputText onchange.
<rf:inputDate value="#{bean.date}" timeValue="#{bean.time}">
<a4j:support event="onchange" reRender="text1" />
</my:timeTicker>
</rf:inputDate>
<h:outputText id="text1" value="#{bean.time}"/>
XML: I added a property to the inputDate.xml
valueTime
java.lang.Object
Time in ms
<![CDATA["0"]]>
JSPX: I added the respective/another inputfield with a modified getValueAsString, pointing to the binding attribute timeValue
<input id="#{clientId}time"
name="#{clientId}time"
type="text"
value="#{this:getValueAsString(context, component,'timeValue')}"
class="my-inputDate-input #{component.attributes['inputClass']}"
style="#{component.attributes['inputStyle']}"/>
JAVA: Modified the DateTimeRenderBase to add the extra method
public String getInputValue(FacesContext context, UIInput component, Object property){
UIInput input = (UIInput) component;
String value = (String) input.getSubmittedValue();
if(value == null){
Object curVal = input.getValue();
Converter converter = SelectUtils.getConverterForProperty(context, input, 'timeValue');
if(converter != null){
value = converter.getAsString(context, input, curVal);
} else {
if(curVal == null){
value = "";
} else {
value = curVal.toString();
}
}
}
if(value == null){
value = "";
}
return value;
}
It does not work since the String value = (String) input.getSubmittedValue();
is always null. (The original value for mybean.time is "1300" )
I'm totally lost, what else I need to modify to make the binding work so that the outputlabel is updated.
Thanks in advance,
Igor
PS:
I previously read, which I could not get anything understandable.
http://www.jboss.org/index.html?module=bb&op=viewtopic&t=150001