Any hint or advice? -- Regards, Michael Xu (xudong) www.wizitsoft.com | Office: (8610) 6267 0615 ext 806 | Mobile: (86) 135 0135 9807 | Fax: (8610) 62670096
On Thu, Jan 7, 2010 at 12:29 PM, Michael Xu (xudong) <[email protected]>wrote: > hi all, > > In ofbiz form, we can use lookup controller for fields which link to > entities. But the lookup controller only support to return single value. How > to implement a multiple lookup? > > Looking into source code, it seems that we have to extend a new controller > in form widget schema and implement it in the form render. Is it a correct > way to go? > > BTW: In my opinion, it is not flexible to extend form widget in current > design. (correct me if I am wrong). Let's take one example. > > <form name="AssignGlAccount" type="single" > target="createGlAccountOrganization" title="" default-map-name="account" > header-row-style="header-row" default-table-style="basic-table"> > <field name="glAccountId"> > <drop-down> > <entity-options entity-name="GlAccount" > description="${accountCode} - ${accountName} [${glAccountId}]"> > <entity-order-by field-name="accountCode"/> > </entity-options> > </drop-down> > </field> > ... > </form> > > Here, we have to use <drop-down> tag to tell system to render a HTML > drop-down component. But what if a customized field? Then do we have to > change form widget schema for that field? And then add the render logic in > the long switch-cases? > > Maybe we can refactor the design, like this: > > <form name="AssignGlAccount" type="single" > target="createGlAccountOrganization" title="" default-map-name="account" > header-row-style="header-row" default-table-style="basic-table"> > <field name="glAccountId"> > <controller name="drop-down"> > <!-- > for new non-standard controller, we can define like this: > <controller name="org.ofbiz.FancyDropDown"> > --> > <param key="entity-name" value="GLAccount"/> > <param key="description" value="...."/> > <param key="entity-order-by" value="accountCode"/> > <!-- > for new non-standard controller, we can define new > parameters > --> > </field> > ... > </form> > > with the new design, then we don't need to break the schema and change the > core code of render logic. Instead, we just need to implement a new > controller from a predefined controller interface. And then we can reuse it > in all forms. > > (In here, due to the limitation of current form widget, we have to give up > form and use FTL directly.) > > -- > Regards, > Michael Xu (xudong) > www.wizitsoft.com | Office: (8610) 6267 0615 ext 806 | Mobile: (86) 135 > 0135 9807 | Fax: (8610) 62670096 >
