0

I'm trying to modify fields scaffolding code using fields plugin. I installed twitter bootstrap also. Now I want to show 2 fields in one row. I did the following in my _form.gsp template file:

private renderFieldForProperty(p, owningClass,counter, prefix = "") {
    boolean hasHibernate = pluginManager?.hasGrailsPlugin('hibernate')
    boolean display = true
    boolean required = false
    if (hasHibernate) {
        cp = owningClass.constrainedProperties[p.name]
        display = (cp ? cp.display : true)
        required = (cp ? !(cp.propertyType in [boolean, Boolean]) && !cp.nullable && (cp.propertyType != String || !cp.blank) : false)
    }
    if (display) {
        if(counter%2==0){
            %><div class="row-fluid"><%
            }
         %>
         <f:field bean="${domainClass.propertyName}" property="${p.name}"/>
<% 
counter++
if(counter%2==0){
            %></div><%
}
 }   } %>

Now the generated code is as follows:

<div class="row-fluid">
         <f:field bean="patient" property="familyName"/>

         <f:field bean="patient" property="firstName"/>
</div>

When I try to view the code in browser I got this exception:

URI
    /patient/create
Class
    org.springframework.beans.NotReadablePropertyException
Message
    Invalid property 'familyName' of bean class [java.lang.String]: Bean property 'familyName' is not readable or has an invalid getter method: Does the return type of the getter match the parameter type of the setter?

I guess I did something wrong with am I right? How could I solve this?

Thanks, Feras

Feras Odeh
  • 9,136
  • 20
  • 77
  • 121

1 Answers1

1

It seems that field tag couldn't resolve "patient" bean. Depending on your scaffolding model, you may need to enclose "patient" (your bean) in ${}, or define a variable named "patient" in your page.

Farshid Zaker
  • 1,960
  • 2
  • 22
  • 39