Actually the difference between parameters in set and get methods appeared because I was
trying different combination of collections.
It was my mistake.
Now as you said the I have following code:
| @Name("personHome")
| public class PersonHome extends EntityHome<Person> {
|
| public List<Country> countries = new ArrayList<Country>();
| public long countryId = 1;
|
|
| public long getCountryId() {
| return countryId;
| }
|
| public void setCountryId(long countryId) {
| this.countryId = countryId;
| }
|
| public void setCountries(List<Country> countries) {
|
| }
|
| public List<Country> getCountries(){
| Country country = new Country();
| country.setId(1);
| country.setName("Poland");
| countries.add(country);
|
| return countries;
| }
| }
|
And xhtml:
|
| <h:selectOneMenu value="#{personHome.countryId}"
converter="#{countryConverter.converter}">
| <s:selectItems value="#{personHome.countries}"
var="country" label="#{country.name}" />
| </h:selectOneMenu>
|
|
And a converter which is based on ui seam example:
|
| @Name("countryConverter")
| public class CountryConverter {
| Converter getConverter(){
| return new Converter(){
| @Transactional
| public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2)
throws ConverterException
| {
| if (arg2 == null) {
| return null;
| }
| try {
| return ((EntityManager)
Component.getInstance("entityManager")).find(Country.class,
Integer.valueOf(arg2));
| } catch (NumberFormatException e) {
| throw new ConverterException("Cannot find selected country",
e);
| }
| }
|
| @Transactional
| public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2)
throws ConverterException
| {
| if (arg2 instanceof Country)
| {
| Country country = (Country) arg2;
| return (new Long(country.getId())).toString();
| }
| else
| {
| return null;
| }
| }
|
| };
| }
|
| }
|
But I still get error:
| Value is no String (class=java.lang.Long, value=1) and component person:_id38with
path: {Component-Path : [Class: org.ajax4jsf.framework.ajax.AjaxViewRoot,ViewId:
/specialist/spec_registration.xhtml][Class: javax.faces.component.html.HtmlForm,Id:
person][Class: org.jboss.seam.ui.UIValidateAll,Id: _id7][Class:
org.jboss.seam.ui.UIDecorate,Id: _id37][Class:
javax.faces.component.html.HtmlSelectOneMenu,Id: _id38]} does not have a Converter
|
|
I don't know where the error comes from and why the converter is not visible.
I would apprecite any suggestions.
jquery
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026894#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...