• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using Object Properties in EL  RSS feed

 
Babak Shimir
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will start out up front, I think my problem is that I am missing some aspect of what defines a "property" for the Bean resolver....

I am trying to follow along with the "Scriptless JSP" articles by Bear Bibeault (http://www.coderanch.com/t/287764/JSP/java/Scriptless-JSP-Pages-Power-Map) and re-write a form from the project that I have been playing with and using to learn. Anyway, it works great when I toss a Map object into a Request Attribute and forward the request along.

I am trying to generate a form, such that it produces a table of attributes, their values, and a drop down box to set the access control.

As such the simple first step was to make a SortedMap (TreeMap) keyed on the attribute name. Then use a c:foreach jstl tag to iterate the entries.
So far so good. However, each attribute has several associated values.

What made the most sense to me was to take the first example, from the article, and make properties with access methods that I can easily make use of. All I need are a couple that return strings, and a couple that return maps. I had many problems, so I decided to break it down and be simple, and add the entirely redundant "Name" property to get the Attribute Name. I added the following methods to my class and made it implement serializable (as some docs that I found claimed that this was one of the fundamental properties of a bean):

Then Proceded to try and acces the Name property:


This should print out the same value twice. If I remove the " ${entry.value.Name }", it works fine, printing it out once. If I leave it in, I get this error:
javax.el.PropertyNotFoundException: Property 'Name' not found on type test.FormAttribute

test.FormAttribute is the right class, It is found (I imported it above). The article, and several sites, talk about editing the TLD file for custom tags or functions, however, I have seen little to no reference on how to actually define a property aside from the naming convention and format of the methods.

I have learned that when google doesn't give me the answer its either because a problem is way too obscure, or its covered in simple documentation that everyone else has seen. Clearly I am missing something, because I can't imagine that this is an obscure thing to want to do.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Case counts.
 
Babak Shimir
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did I say? I must be missing something simple.

It totally wasn't clear that getName would get de-capitalized down to "name" but, that makes a certain amount of sense.

Many thanks for the reply, and even more for the articles. I can already see my forms getting cleaner....way cleaner.

 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Babak Shimir wrote:It totally wasn't clear that getName would get de-capitalized down to "name" but, that makes a certain amount of sense.

This is normal JavaBeans naming rules.

Many thanks for the reply, and even more for the articles. I can already see my forms getting cleaner....way cleaner.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!