Inheritance and DefaultBeanPropertyTableProvider

View: New views
4 Messages — Rating Filter:   Alert me  

Inheritance and DefaultBeanPropertyTableProvider

by wadi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All! I'm having troubles displaying data on a beantable. I have two clases :
public class A implements Identifieable<Integer>,Serializable{
...
}
public class B exends A{
...
}

If I create DefaultBeanPropertyTableProvider(B.class, criteria) I don't see the rows, only the header.
If I create DefaultBeanPropertyTableProvider(A.class, criteria) I  see the rows.
How should I handle this?I need to display propertys of class B.
On the other hand, how can I change the BeanFilterPanel "Filter" text?Can I use something
like CreateBeanPanel(...,new Model("Search")....


Thanks in advance,
Regards,
Wadi

Re: Inheritance and DefaultBeanPropertyTableProvider

by wfaler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

As for BeanFilterPanel: I don't quite recall to be honest, although I would say that this is more a "convenience" implementation than anything else - if you want to customize it further maybe doing your own implementation is best (I'll try to improve it in the future).

As for your actual problem, it is hard to say, do you think you could attach the code of bean A and B?
Normally, I think the properties of A should be visible on B as they are inherited, but if you have properties on B you will need to annotate their getters as well with the *Property annotations in the org.wicketrad.propertytable.annotations package.

wadi wrote:
Hi All! I'm having troubles displaying data on a beantable. I have two clases :
public class A implements Identifieable<Integer>,Serializable{
...
}
public class B exends A{
...
}

If I create DefaultBeanPropertyTableProvider(B.class, criteria) I don't see the rows, only the header.
If I create DefaultBeanPropertyTableProvider(A.class, criteria) I  see the rows.
How should I handle this?I need to display propertys of class B.
On the other hand, how can I change the BeanFilterPanel "Filter" text?Can I use something
like CreateBeanPanel(...,new Model("Search")....


Thanks in advance,
Regards,
Wadi

Re: Inheritance and DefaultBeanPropertyTableProvider

by wadi :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi! Thanks for your answer.
THe code would look like this:
Class A would be this:
@Entity
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)

public abstract class User implements Identifiable<Integer>, Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.TABLE)
    @Column(name = "ID")
    private Integer id;
    @Column(name = "NOMBRE")
    private String nombre;


    @LabelProperty
    @TextField
    @Required
    @Sortable
    @Searchable
    @FieldOrder(1)
    @EditScope(Scope.CREATE)
    @BeanLinkProperty(UpdatePageToRuleThemAll.class)
    public String getCodigo() {
        return codigo;
    }

    @org.wicketrad.annotation.FieldOrder(1)
    @LabelProperty
    @TextField
    public String getNombre() {
        return nombre;
    }

    public void setCodigo(String codigo) {
        this.codigo = codigo;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }
    @Column(name = "CODIGO")
    private String codigo;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return nombre;
    }
}


And class B looks like this:



@Entity
@Table(name = "CLINIC_USER_STATE")
public class EstadoUsuarioClinico extends User  {

   //TODO implementar el serializar

 
}

Thanks in advance,
regards,
Wadi

Re: Inheritance and DefaultBeanPropertyTableProvider

by wfaler :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hmm.. As far as I can see it should work (properties of the first class being shown)..

However, is it possible your JPA mappings are not correct (in other words: causing the JPA query not to be correctly built?). I've never actually used JPA inheritance like you show, so I'm not sure it's correct.

The second possibility is of course that this is a genuine bug - I found a bug related to validation of composite id's a few days ago as well.
I guess this goes onto my list of things to look at and potentially fix, although I probably won't be able to do so until the weekend (although a new release is in the works).

In the meantime, I think if it is not a problem with the JPA mappings (double check this with the docs), the best option is probably to implement your own tableprovider that fixes this issue, and/or use the Wicket RAD source for the table provider you do use and fix it there (if you do the latter, please send me the fix! :D).
I'm pretty sure if this is a bug (which I will double check) - the problem lies in the tableprovider, as you say you can see the headings but no  results (indicating the problem is in the JPA lookup and/or count).