Home No such property: propertyName for class: org.grails.orm.hibernate.cfg.HibernatePersistentEntity
Reply: 0

No such property: propertyName for class: org.grails.orm.hibernate.cfg.HibernatePersistentEntity

user6930
1#
user6930 Published in June 19, 2018, 2:32 pm

im new to grails, and i want to style my f:table in the index.gsp, i created a file _table.gsp, when i execute i get this error : No such property: propertyName for class: org.grails.orm.hibernate.cfg.HibernatePersistentEntity

index.gsp

<!DOCTYPE html>
<html>
<head>
<meta name="layout" content="main" />
<g:set var="entityName" value="${message(code: 'user.label', default: 'User')}" />
<title><g:message code="default.list.label" args="[entityName]" /></title>
</head>
<body>
<div class="breadcrumbs">
<div class="col-sm-3">
<a href="#list-user"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
</div>
<div class="col-sm-3">
<a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a>
</div>
<div class="col-sm-3">
<g:link class="create" action="create"><g:message code="default.new.label" args="[entityName]" /></g:link>
</div>
</div>
<br>
<br>
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header">
<strong class="card-title"><g:message code="default.list.label" args="[entityName]" /></strong>
</div>
<div class="card-body">
<div id="pay-invoice">
<div class="card-body">
<div id="list-user" class="content scaffold-list" role="main">
<g:if test="${flash.message}">
<div class="message" role="status">${flash.message}</div>
</g:if>
<f:table collection="${userList}"/>    
<div class="pagination">
<g:paginate total="${userCount ?: 0}" />
</div>
</div>
</div>
</div>
</div>
</div> <!-- .card -->
</div>
</div>
</body>
</html>

_table.gsp

<table class="table stripped-table">
<thead>
<tr>
<g:each in="${domainClass}" var="p" status="i">
<g:set var="propTitle">${domainClass.propertyName}.${p.name}.label</g:set>
<g:sortableColumn property="${p.name}" title="${message(code: propTitle, default: p.naturalName)}" />
</g:each>
</tr>
</thead>
<tbody>
<g:each in="${collection}" var="bean" status="i">
<tr class="${(i % 2) == 0 ? 'even' : 'odd'}">
<g:each in="${domainProperties}" var="p" status="j">
<g:if test="${j==0}">
<td><g:link method="GET" resource="${bean}"><f:display bean="${bean}" property="${p.name}" displayStyle="${displayStyle?:'table'}" /></g:link></td>
</g:if>
<g:else>
<td><f:display bean="${bean}" property="${p.name}"  displayStyle="${displayStyle?:'table'}" /></td>
</g:else>
</g:each>
</tr>
</g:each>
</tbody>
</table>

User.groovy

class User {

transient securiteService

String username
String password
String nom
String prenom
String email
String tel

static hasMany = [roles : Role]

static constraints = {
    username blank: false, unique: true
    password blank: false
    nom nullable: true
    prenom nullable: true
    email email:true, nullable:true
    tel nullable:true, maxSize:20,  matches:/[\+]{0,1}[0-9\s]{3,15}/
}

static mapping = {
    password column: '`password`'
    sort nom: "asc"
    affectations sort : "dateAffectation", order:"desc"
    intervention sort : "responsable", order:"desc"
}
}

usercontroller.groovy :

package mylicence

import grails.validation.ValidationException
import static org.springframework.http.HttpStatus.*
import java.security.MessageDigest

class UserController {

UserService userService

static allowedMethods = [save: "POST", update: "PUT", delete: "DELETE"]

def index(Integer max) {
    params.max = Math.min(max ?: 10, 100)
    respond userService.list(params), model:[userCount: userService.count()]
}

def show(Long id) {
    respond userService.get(id)
}

def create() {
    respond new User(username: params.username, password: params.password, nom: params.nom, prenom: params.prenom, email: params.email, tel: params.tel)
}

def save(User user) {
    if (user == null) {
        notFound()
        return
    }

    try {
        userService.save(user)
    } catch (ValidationException e) {
        respond user.errors, view:'create'
        return
    }

    request.withFormat {
        form multipartForm {
            flash.message = message(code: 'default.created.message', args: [message(code: 'user.label', default: 'User'), user.id])
            redirect user
        }
        '*' { respond user, [status: CREATED] }
    }
}

def edit(Long id) {
    respond userService.get(id)
}

def update(User user) {
    if (user == null) {
        notFound()
        return
    }

    try {
        userService.save(user)
    } catch (ValidationException e) {
        respond user.errors, view:'edit'
        return
    }

    request.withFormat {
        form multipartForm {
            flash.message = message(code: 'default.updated.message', args: [message(code: 'user.label', default: 'User'), user.id])
            redirect user
        }
        '*'{ respond user, [status: OK] }
    }
}

def delete(Long id) {
    if (id == null) {
        notFound()
        return
    }

    userService.delete(id)

    request.withFormat {
        form multipartForm {
            flash.message = message(code: 'default.deleted.message', args: [message(code: 'user.label', default: 'User'), id])
            redirect action:"index", method:"GET"
        }
        '*'{ render status: NO_CONTENT }
    }
}

protected void notFound() {
    request.withFormat {
        form multipartForm {
            flash.message = message(code: 'default.not.found.message', args: [message(code: 'user.label', default: 'User'), params.id])
            redirect action: "index", method: "GET"
        }
        '*'{ render status: NOT_FOUND }
    }
}

def login() {

}

def handlelogin = {
    def hashPassd = params.password
    // Find the username
    def user = User.findByUsernameAndPassword(params.username, hashPassd)
    if (!user) {
        flash.message = "User not found for userName: ${params.username}"
        redirect(action:'login')
        return
    } else {
        session.user = user
        redirect(controller:'user')
    }
}

def logout = {
    //log.info 'logout'
    if(session.user) {
        session.user = null
        session.invalidate()
        redirect(controller:'user', action: 'login')
    }
    else {
        redirect(controller:'user', action: 'login')
    }
}

}

i searched every where with no solution, im using grails 3.3.4, groovy 2.4.14, JVM 1.8.0_161

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.351699 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO