0

I have the below piece of code:

  <h:selectOneMenu value="#{serviceBean.selectedCountry}" class="form-control" id="code">

                    <f:selectItems value="#{serviceBean.countryVos}" var="s"
                                   itemValue="#{s.id}" itemLabel="#{s.name} #{s.countryCode}"/>

   </h:selectOneMenu>

and the below in my MangedBean :

@ManagedBean(name = "serviceBean")
@ViewScoped
public class ServiceBean extends ServiceConfig implements Serializable {

  private List<CountryVo> countryVos;
  private String selectedCountry;


  private void getCountry() {
        try {

            this.countryVos = CountryDao.getInstance().getCountryData();
            
            ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
            Map<String, Object> sessionMap = externalContext.getSessionMap();
            
            sessionMap.put("countryVos", this.countryVos);

        } catch (Exception ex) {
            Logger.getLogger(ServiceBean.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    public String getSelectedCountry() {
        return selectedCountry;
    }

    public void setSelectedCountry(String selectedCountry) {
        this.selectedCountry = selectedCountry;
    }

}

I want to return in the selectedCountry the Object countryVo not the String of it, how can I do this? when I tried to return object I got the below error :

Conversion Error setting value '33' for 'null Converter

33 is the value of the selected country id

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
yasmin
  • 15
  • 6
  • what is the warehouseService ```return warehouseService.find(Long.valueOf(submittedValue));``` I don't know when to implement it I did all the steps but it cant finds the method find ?! please help – yasmin Oct 28 '20 at 08:02
  • Check with the person who provided you with the `CountryDao`. – Jasper de Vries Oct 28 '20 at 08:04
  • should I add ```find()``` method in the ```CountryDao``` to search for the submitted data please answer?? – yasmin Oct 28 '20 at 08:07

0 Answers0