grails - how to displaydomain value in gsp -


i have 3 domain class

class stock {    product product } 

and

class product {    productname productname } 

and

class productname {    string name } 

in create.gsp of stock domain, default code generation:-

<tr class="prop">   <td valign="top" class="name">     <label for="name">       <g:message code="stock.name.label" default="product name" />     </label>   </td>   <td valign="top" class="value ${haserrors(bean: stockinstance, field: 'name', 'errors')}">     <g:select name="product.id"               from="${com.ten.hp.his.pharmacy.product.list()}"               optionkey="id"               optionvalue="productname"               value="${stockinstance?.product?.id}"  />   </td> </tr> 

my requirement display product name in drop down using optionvalue, showing productname id like, com.ten.productname:1. how can show, product name in drop down.

jigar answer correct based on data model. grails select tag expects optionvalue name of bean property of element (product). select tag call tostring() on value work need override tostring() method of productname class.

it possible specify within gsp want "name" property of productname passing closure code optionvalue.

optionvalue="${{it.productname.name}}" 

Comments

Popular posts from this blog

How do you change vbulletin's home page to the forums instead of the default (CMS or Activity Stream)? -

c++ - Troubles when compiling phash program -