Ich werde einen benutzerdefinierten Datentyp für meine Eingabefelder erstellen. (siehe Klassen "Betrag"). Das Setzen des Wertes im Eingabefeld "amountId" funktioniert einwandfrei. Aber, wenn ich das Formular abschicken und auf eine andere Seite gehen möchte, dann habe ich die Ausnahme "argument type mismatch".JSF 2.0; "Argumenttyp stimmt nicht überein" von der benutzerdefinierten Datentypklasse?
Kann mir jemand erklären, warum ich diese Ausnahme bekomme?
- Muss ich einen Konverter benötigen den Eingangswert in String zu konvertieren?
- Habe ich vergessen, einige Methoden in meiner Amount-Klasse zu implementieren, die JSF benötigt, um die Werte zu erhalten?
Hier ist mein 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)
Ich denke, man sollte hinzufügen Konverter zu Ihrem
Daniel
Oh, ein Konverter zu übermitteln hat mir geholfen :) vielen Dank !! – Tobi