Where does variable 'contacts' came from in the book about Stripes?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Where does variable 'contacts' came from in the book about Stripes?

tika
I'm currently only reading the book "Stripes: ...and Java web development is fun again".
Since I'm not new to web development, I'm able to read this book without practicing in editor.

I have spot a problem on page 47 in the following line:

<c:forEach var="contact" items="${actionBean.contacts}">

What is this reference "contacts"? It is not explicitly declared in the action bean. It does exist only in this method name:

public List<Contact> getContacts() {
   return contactDao.read();
}

So, was the "contacts" reference accidentally dropped from the code or Stripes perhaps uses implicit declarations according to some naming conventions, e.g. method naming? I believe that it was accidentally dropped, since in the first chapter a "date" reference was used in similar way, but now I'm not sure that there is not some kind of implicit declarations since Stripes forces convention over configuration.

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Where does variable 'contacts' came from in the book about Stripes?

Rick Grashel
Hi Tika,

That reference is just standard JSP EL notation that references a getter method on a bean.  So "actionBean.contacts" will execute the method actionBean.getContacts().  This is a common way that Java/JSP web applications call into Java classes in order to execute accessor (getter) methods.

-- Rick

On Wed, Dec 23, 2015 at 11:10 AM, Tika Spic <[hidden email]> wrote:
I'm currently only reading the book "Stripes: ...and Java web development is fun again".
Since I'm not new to web development, I'm able to read this book without practicing in editor.

I have spot a problem on page 47 in the following line:

<c:forEach var="contact" items="${actionBean.contacts}">

What is this reference "contacts"? It is not explicitly declared in the action bean. It does exist only in this method name:

public List<Contact> getContacts() {
   return contactDao.read();
}

So, was the "contacts" reference accidentally dropped from the code or Stripes perhaps uses implicit declarations according to some naming conventions, e.g. method naming? I believe that it was accidentally dropped, since in the first chapter a "date" reference was used in similar way, but now I'm not sure that there is not some kind of implicit declarations since Stripes forces convention over configuration.

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users
Reply | Threaded
Open this post in threaded view
|

Re: Where does variable 'contacts' came from in the book about Stripes?

VANKEISBELCK Remi
In reply to this post by tika
Hi,

When you write this in EL :

${actionBean.contacts}

It actually looks for a JavaBean property named "contacts" on an object named "actionBean" bound to a JSP scope (here, request). In that case, it ends up invoking "getContacts".

Cheers

Rémi


2015-12-23 18:10 GMT+01:00 Tika Spic <[hidden email]>:
I'm currently only reading the book "Stripes: ...and Java web development is fun again".
Since I'm not new to web development, I'm able to read this book without practicing in editor.

I have spot a problem on page 47 in the following line:

<c:forEach var="contact" items="${actionBean.contacts}">

What is this reference "contacts"? It is not explicitly declared in the action bean. It does exist only in this method name:

public List<Contact> getContacts() {
   return contactDao.read();
}

So, was the "contacts" reference accidentally dropped from the code or Stripes perhaps uses implicit declarations according to some naming conventions, e.g. method naming? I believe that it was accidentally dropped, since in the first chapter a "date" reference was used in similar way, but now I'm not sure that there is not some kind of implicit declarations since Stripes forces convention over configuration.

------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users



------------------------------------------------------------------------------

_______________________________________________
Stripes-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-users