1 Reply Latest reply on Feb 23, 2012 3:21 AM by omid pourhadi

    how can i get a selected value for a 'f:selectItems' when the options are foreign from other table?

    Liliana Ortiz Newbie


      I have 2 tables: 1. client (id, name, company_id) 2. company(id,name)


      I need create a  filter with the fields (from the table client) from other table (company) and I can create the list but i can´t get the value selected by the user.

      I have the files:

      • clientList.xhtml
      • ClientList.page.xml
      • ClientList.java
      • Client.java
      • Company.java


      As the table client has a foreign key to the table company the class Client has a object of the class company then I access to the company selected with the tag



      my xhtml:




                              <f:selectItems value="#{listCompanies}" />

                              <s:convertEntity />


      It´s ok this shows the select list.


      my clientList.page.xml




         <param name="from"/>

         <param name="client.company.id" value="#{clientList.client.company.id}" />


      my ClientList.java


      private static final String EJBQL = "select client from Client client";

      private static final String[] RESTRICTIONS = { "client.company.id =(#{clientList.client.company.id})", };


      my Client.java


          private Integer id;

          private Company company;

          private String name;




      But when the user select an option it does not work.

        • 1. Re: how can i get a selected value for a 'f:selectItems' when the options are foreign from other table?
          omid pourhadi Apprentice

          First of all you are using convertEntity so you need this code




                                  <f:selectItems value="#{listCompanies}" />

                                  <s:convertEntity />



          remove id


          then whereever the listCompanies is coming from use this



          if you have problem as far as i concern company is targetunreachable while you r accessing it from client

          define it as seam component in components.xml as a property of client