1 Reply Latest reply on Apr 15, 2009 3:47 PM by Eduard Korenschi

    Generate-ui with two fields of the same entity on one entity

    Eduard Korenschi Newbie
      Hi there, I want to report a problem and a very simple way to solve it:
      Let's say I have this Invoice with a Customer and Supplier (both of Company type)
      public class Invoice {
          private Company Customer

          private Company Supplier

      Once you ask Seam (2.1.2 snapshot as of today) to generate-ui it will mess up things. It will create only one companyHome in InvoiceHome and those two fields will be treated as one (when you try to select the Customer, both the customer and supplier get the same value).

      The simple solution I found is the following one
      1. CompanyHome should receive two roles
      2. All Invoicexxxxx.page.xml should be adapted, replacing
         <param name="companyFrom"/>
         <param name="companyId" value="#{companyHome.invoiceId}"/>
         <param name="customerFrom"/>
         <param name="customerId" value="#{customerHome.invoiceId}"/>
         <param name="supplierFrom"/>
         <param name="supplierId" value="#{supplierHome.invoiceId}"/>
      3. in InvoiceEdit.xhtml, the button for selecting the customer should receive one more param:
                    <f:param name="fieldName" value="customer"/>
      and the one selecting the supplier should receive
                    <f:param name="fieldName" value="supplier"/>
      4. CompanyList.page.xml should have the following parameter added:
                    <param name="field"/>
      5. CompanyList.xhtml should have the action link updated to:
            <s:link view="/#{empty from ? 'Company' : from}.xhtml"
                         value="#{empty from ? 'View' : 'Select'}"
                   propagation="#{empty from ? 'none' : 'default'}"
                      <f:param name="#{empty fieldName ? 'company' : fieldName}Id"

      That should do it ...

      Now my question is : is there any way to make this thing work like this out of the box, or is it possible to incorporate in seam-gen this logic?

      Eduard Korenschi