Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

a question about petstore  RSS feed

 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all.
I have some questions about the petstore demo.
the catalog.jsp page under the petstore dir have the following code :
<c:set value="${catalog.products}" var="pageResults"/>
catalog object is an instance of com.sun.j2ee.blueprints.catalog.client.CatalogHelper
this instance has no field called products nor a method, so what this is mean ?
also, in the same page there is the following line :
<c:forEach var="item" items="${pageResults.list}" >
pageResults is a var from the first tag, but what list does mean ?
is it a predifiend variable ?
any reponse is welcome.
(I am novice in custom tags)
thanks.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
c:set value="${catalog.products}" var="pageResults"/>
catalog object is an instance of com.sun.j2ee.blueprints.catalog.client.CatalogHelper
this instance has no field called products nor a method, so what this is mean ?


products is a property so its accessor will be getProducts(). The EL works with beans and properties. Look up and become familiar with the pattern of Java beans.
[ June 12, 2004: Message edited by: Bear Bibeault ]
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks.
but do you mean that the EL is accessing the method getProducts( ) of CatalogHelper ?
can the EL access the methods of a component ?

products is a property

sorry but I don't understand what do you mean here.
do you mean it is a property of CatalogHelper or a property from another source ?
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two more questions please.
if you visit the petstore demo for the first time, a databse will be
populated with data.
how the application perform this ? which component is responsible for this ?
there is a file called CatalogDAOSQL.xml which contains sql commands
but I don't know which component use it.
second q :
all pages have the same view (I mean a header , footer .....), but when looking at a page (any page like product.jsp or catalog.jsp, there is no including functionality.
how the demo do this ?
last one :
<c:forEach var="item" items="${pageResults.list}" >
is the EL now calling a method called getList( ) ?
Thanks.
[ June 13, 2004: Message edited by: John Todd ]
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Following my suggestion of reading up on Java beans will answer most of your questions.
 
Hussein Baghdadi
clojure forum advocate
Bartender
Posts: 3479
Clojure Mac Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Bear.
I don't want stammerer but let me discuss the following :
(I am already familiar with beans).
if the bean has an instance field called firstName, the bean
will has a setter and getter methods for this field.
now, when writing :
<c ut value="${bean.firstName}"/>
the EL will access the field useing the corresponding method,
something like <%= bean.getFirstName( ) %>
right ?
but I am confused because the CatalogHelper has no field called products.
yes, it has a method getProducts( ) but not a field.
there is a similiar example here :
<c:if test="${pageResults.nextPageAvailable == true}">
pageResutls is an instance of Page class, this class has no field called
nextPageAvailable, there is a method called isNextPageAvailable( ).
it seems to me that EL can use a method of some class.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65825
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The whole point of beans is that the fields do not matter. That's why they are private. All that matters is the properties that are exposed with the accessors and mutators (getters and setters).
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!