Announcement Announcement Module
Collapse
No announcement yet.
How to hide a drop-down list (generated by a reference)? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to hide a drop-down list (generated by a reference)?

    Hi everybody. I have a question. I'm developing a grails app where I have many users. As I'm using Spring Security I can obtain a reference to the logged user. Here's my domain classes:

    class Recepcion {
    String nombre
    Date fechaDeRecepcion
    String numeroDeSacos
    BigDecimal peso
    String placaDeAutomovil
    String numeroDeTornaguia
    Date fechaDeTornaguia

    static belongsTo = [usuario: Usuario, proveedor: Proveedor]

    static constraints = {
    ...
    }
    }

    class RecepcionDeCobre extends Recepcion{
    Integer loteCu
    transient springSecurityService

    def beforeInsert = {
    def c = RecepcionDeCobre.createCriteria()
    def results = c {
    projections {
    max('loteCu')
    }}
    def maxLote = results.get(0)?: 0
    this.loteCu = maxLote + 1
    this.usuario = springSecurityService.getCurrentUser() <--obtaining logged user reference
    }

    static constraints = {
    loteCu( display: false, nullable: true )
    }
    }

    class Usuario extends SecUser{ // SecUser was generated with a Spring Security command
    String nombre
    String apellido
    String email
    String puntoDeTrabajo

    static constraints = {
    ...
    }
    }

    The create view for RecepcionDeCobre in the field Usuario show a list containing all the registered users. How can I hide this list? As I can get the logged user this seems redundant and unnecessary. I deleted the code for this list and its label directly in its GSP but when I want to register new data it produces an error message that says "Usuario cannot be null" what is perfectly correct. Again, how can I hide this list preventing this error and having a reference to the logged user?

    Thanks in advance.
Working...
X