I'm going to create a custom data type for my input fields. (see clas "Amount"). Setting the value in the inputfield "amountId" does work perfect. But, if i want to submit the form and go to another page, then i've got the "argument type mismatch" exception.
Can someone explain me, why i get this exception?
- Do i need a converter to convert the input value to string?
- Have i forgot some methods in my Amount class to implement, which JSF needs to get the values?
Here is my code:
public class Amount implements Serializable {
public Amount(BigDecimal bd){
}
public Amount(String s) {
}
@Override
public String toString() {
}
}
@ManagedBean(name="myBean")
@RequestScoped
public class MyBean extends BaseBean {
private Amount amountValue;
private UIInput amountValueId;
public Amount getAmountValue() {
return amountValue;
}
public void setAmountValue(Amount amountValue) {
this.amountValue = amountValue;
if (this.amountValueId != null)
this.amountValueId.setSubmittedValue(amountValue);
}
public UIInput getAmountValueIdId() {
return amountValueId;
}
public void setAmountValueId(UIInput amountValueId) {
this.amountValueId = amountValueId
}
}
<h:inputText id="amountValueId" binding="#{myBean.amountValueId}" size="30" value="#{myBean.amountValue}" />
javax.servlet.ServletException: javax.el.ELException: java.lang.IllegalArgumentException: argument type mismatch
javax.faces.webapp.FacesServlet.service(FacesServlet.java:229)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)
org.apache.myfaces.view.facelets.el.ContextAwareELException: javax.el.ELException: java.lang.IllegalArgumentException: argument type mismatch
org.apache.myfaces.view.facelets.el.ContextAwareTagValueExpression.setValue(ContextAwareTagValueExpression.java:166)
javax.faces.component.UIInput.updateModel(UIInput.java:406)
javax.faces.component.UIInput.processUpdates(UIInput.java:328)
javax.faces.component.UIForm.processUpdates(UIForm.java:263)
javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1469)
javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1469)
javax.faces.component.UIComponentBase.processUpdates(UIComponentBase.java:1469)
javax.faces.component.UIViewRoot._processUpdatesDefault(UIViewRoot.java:1397)
javax.faces.component.UIViewRoot.access$600(UIViewRoot.java:74)
javax.faces.component.UIViewRoot$UpdateModelPhaseProcessor.process(UIViewRoot.java:1535)
javax.faces.component.UIViewRoot._process(UIViewRoot.java:1358)
javax.faces.component.UIViewRoot.processUpdates(UIViewRoot.java:806)
org.apache.myfaces.lifecycle.UpdateModelValuesExecutor.execute(UpdateModelValuesExecutor.java:38)
org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:170)
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:357)