aspose file tools*
The moose likes Struts and the fly likes encapsulate data easy question.. begginer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "encapsulate data easy question.. begginer " Watch "encapsulate data easy question.. begginer " New topic
Author

encapsulate data easy question.. begginer

slav agui
Greenhorn

Joined: Jan 15, 2008
Posts: 4
Hello,
I am trying to undertand how encapsulate data works.
I have:
TestEncapsulate userdata = new TestEncapsulate (
rs.getString("name")==null?"":rs.getString("name"),
rs.getString("last")==null?"":rs.getString("last"),
rs.getString("midd")==null?"":rs.getString("mid")
) ;
was working, good. But another programmer told me that was missing:
userdata.setname(request.getParameter("name"));
userdata.setlast(request.getParameter("last") );
userdata.setmidd(request.getParameter("midd"));
So I added (and is working too!). He told me to keep it because is necessary.
I do not undertand why do I need to do the second section if in the first section I put the values, isn't it?.
Some body can explain me this, please?
THANK YOU!
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

I'm not really sure how this is a Struts question.

I suspect the issue the other programmer was talking about is that the JavaBean specification requires getters and setters for bean properties.

Having a constructor that fills all the values is okay, but it's also good practice (and required in many circumstances) to have a default constructor that takes no values, and getters/setters that allow setting and retrieving the bean properties.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: encapsulate data easy question.. begginer