I can't access parent class through child class in JSP

374 views
Skip to first unread message

Anthony Lee

unread,
May 31, 2012, 2:47:20 AM5/31/12
to project...@googlegroups.com
Hi I have something problem.
I'm make good use of lombok lib in my web project.
 
my project is structured by Spring MVC, JSP.
So, I save model object to show in JSP.
 
But I can't access parent model field;
my model class and JSP code is here.
 
---
(Parent class is not applied LOMBOK Annotation)
Parent.java
public class Parent {
 private Long mbrNo;
 private String mbrId;
 
 public void setMbrNo(Long mbrNo){
 }
...
 public void setMbrId(String mbrId){
 }
 
GETTER HERE...
}
 
----
(Child class is applied LOMBOK Annotation)
Child.java
 
@Data
@EqualsAndHashCode(callSuper = false)
public class Child extends Parent {
 private Long charNo;
 private String charId;
}
 
NOW, I will type the model's mbrId filed
But I cant see value;
 
${model.mbrId} (X)
${model.charId} (O)
 
how can i do?
plz help me ;-(

Robbert Jan Grootjans

unread,
May 31, 2012, 7:03:23 AM5/31/12
to project...@googlegroups.com
Just to be 100% clear,

you are saying that ${model.mbrId} does give a value, whilst
${model.charId} does not?
> --
> You received this message because you are subscribed to the Google
> Groups group for http://projectlombok.org/
>
> To post to this group, send email to project...@googlegroups.com
> To unsubscribe from this group, send email to
> project-lombo...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/project-lombok?hl=en

Anthony Lee

unread,
Jun 1, 2012, 1:34:24 AM6/1/12
to project...@googlegroups.com
I did give values both ${model.mbrId} and ${model.charId}.
charId (Child's member field) can take value in JSP.
But mbrId can't (Parent's member field)
 
Additionaly says,
I did print ${model} to JSP.
It may be call model.toString().
that string show like this....
 
(Child = (charId='anthony', ....))
But mbrId was not include in toString's string.

2012년 5월 31일 목요일 오후 3시 47분 20초 UTC+9, Anthony Lee 님의 말:
2012년 5월 31일 목요일 오후 3시 47분 20초 UTC+9, Anthony Lee 님의 말:
2012년 5월 31일 목요일 오후 3시 47분 20초 UTC+9, Anthony Lee 님의 말:
2012년 5월 31일 목요일 오후 3시 47분 20초 UTC+9, Anthony Lee 님의 말:

Robbert Jan Grootjans

unread,
Jun 2, 2012, 2:55:00 AM6/2/12
to project...@googlegroups.com
At this moment, I don't see a direct solution to the problem of mbrId
not being accessible in the JSP class. Lombok only makes changes to
the child class, but the attributes of the inherited class should
remain the same.

As for the toString(), the attributes of the parent class are not
added to the toString, in general, adding @Data does nothing with the
attributes of the Parent class (getters and setters aren't generated
either). If the Parent class has a suitable toString(), you can add
this to the Child class's toString by explicitly adding
@ToString(callSuper=true). @Data does not do this by default and this
cannot be configured on @Data.

Anthony Lee

unread,
Jun 2, 2012, 10:59:19 AM6/2/12
to project...@googlegroups.com, robbe...@dds.nl
I see.
Thank you for aswering my question :-)
> To post to this group, send email to project-lombok@googlegroups.com
> To unsubscribe from this group, send email to
> project-lombok+unsubscribe@googlegroups.com
Reply all
Reply to author
Forward
0 new messages