Hallo,
ich hab die Suche schon benutzt, nur leider hilft mir das bei meinem Problem nicht weiter.
Ich bekomme,wenn ich etwas aus dem SelectOneMenu auswähle, in dem Formular nach dem Klick auf den Button immer die Fehlermeldung:form:application: Validierungs-Fehler: Wert nicht gültig
Ich habe ein SelectOneMenu:
Dann den Controller:
Nächste Klasse
Und mein Converter der wohl noch Probleme macht:
Ich hab gerade ein Brett vorm Kopf und wäre über Hilfe dankbar.
Gruß
ich hab die Suche schon benutzt, nur leider hilft mir das bei meinem Problem nicht weiter.
Ich bekomme,wenn ich etwas aus dem SelectOneMenu auswähle, in dem Formular nach dem Klick auf den Button immer die Fehlermeldung:form:application: Validierungs-Fehler: Wert nicht gültig
Ich habe ein SelectOneMenu:
Code:
<h:form id="form">
<h:selectOneMenu id="application" value="#{ApplicationController.applications}" converter="StringConverter">
<f:selectItems value="#{ApplicationController.applications}" />
</h:selectOneMenu>
</h:form>
Dann den Controller:
Java:
public class ApplicationController
{
private String test ="";
private Application application;
private ArrayList<SelectItem> allRoles = new ArrayList<SelectItem>();
public ApplicationController()
{
allRoles.add(new SelectItem("Wählen Sie"));
allRoles.add(new SelectItem("Option1"));
allRoles.add(new SelectItem("Option2"));
}
public void setApplication(Application application)
{
this.application = application;
}
public ArrayList<SelectItem> getApplications()
{
return this.allRoles;
}
public Application getApplication()
{
return application;
}
}
Nächste Klasse
Java:
public class Application
{
private String application;
public Application(String application)
{
this.application = application;
}
public void setApplication(String application)
{
this.application = application;
}
public String getApplication()
{
return this.application;
}
}
Und mein Converter der wohl noch Probleme macht:
Java:
public class StringConverter implements Converter
{
public StringConverter()
{}
public Object getAsObject(FacesContext context, UIComponent component, String value)
{
SelectItem item=null;
try{
item = new SelectItem(value.toString());
System.out.println("Durchlaufen: " +item.getValue());
}catch( UnsupportedOperationException e){ System.out.println("GetAsObject failed." +e); }
return item;
}
public String getAsString(FacesContext context, UIComponent component, Object value)
{
String myString="";
try{
myString = value.toString();
}catch( UnsupportedOperationException e){ System.out.println("GetAsString failed." +e); }
return myString;
}
Ich hab gerade ein Brett vorm Kopf und wäre über Hilfe dankbar.
Gruß