File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes ValueChangeListener for double values Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "ValueChangeListener for double values" Watch "ValueChangeListener for double values" New topic
Author

ValueChangeListener for double values

Mathandisto Mathandistos
Greenhorn

Joined: Jan 25, 2011
Posts: 1

Hi

I am hoping someone will be able to assist, I am new to jsf and i'm having difficulties with valuechangelistener.

For some odd reason, it's not rendering the total field with the new value. Did I perhaps miss something?

Your assistance will be much appreciated.

in my feesCalculationEdit.xhtml I have

h:form id="feesCalculation">
<table>
<s:decorate id="squareMetersField" template="/layout/edit.xhtml">
<ui:define name="label">Square meters</ui:define>
<h:inputText id="squareMeters" value="#{feesCalculationHome.instance.squareMeters}"
valueChangeListener="#{feesCalculationHome.updateFeeValuesChanged}">
<a:support event="onchange" reRender="squareMetersField,totalField" bypassUpdates="true" ajaxSingle="true"/>
</h:inputText>
</s:decorate>

<s:decorate id="totalField" template="/layout/edit.xhtml">
<ui:define name="label">Total</ui:define>
R<h:inputText id="total" value="#{feesCalculationHome.instance.total}">
<a:support event="onblur" reRender="totalField" bypassUpdates="true" ajaxSingle="true"/>
</h:inputText>
</s:decorate>
</table>
</h:form>

and in my feesCalculationHome bean I have

Map<Double, UIComponent> UIComponent;
public void updateFeeValuesChanged(ValueChangeEvent event) {
System.out.println("A value has changed!");
Double oldSquareMeters = ((double) event.getOldValue()).doubleValue();
Double squareMeters = ((double) event.getNewValue()).doubleValue();
System.out.println("OLD squareMeters = " + oldSquareMeters);
System.out.println("squareMeters = " + squareMeters );
javax.faces.component.UIComponent total = event.getComponent().findComponent(":feesCalculation:totalField:total");
((EditableValueHolder)total).setValue(squareMeters);
FacesContext.getCurrentInstance().renderResponse();
}


Thank you in advance
Mathandisto
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: ValueChangeListener for double values
 
Similar Threads
On selectonemenu change uncheck checkbox?
problem on saving inputText values
Mutiple ComboBoxes using c:forEach
How to prevent values over 99inches but still allow 13.5 inches
Do I need a backing bean to get the character length of the contents in a text-area?