Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Unable to display properties of Collection Bean

 
Rajat Sharmanaive
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I am unable to display the desired properties from beans of a collection in an HTML table. Following is the code.


Please assume:
1. Collection is correctly session scoped.
2. All properties are valid.

I say this because the following prints (properties of the first bean in the collection) just fine:



Please suggest if there are any syntactical mistakes in the problematic code. I have placed <tr> tag inside the <c:forEach> tag because I feel it will generate (sort of a) dynamic table. Although I was pretty sure it would change nothing, I still tried placing the table opening and closing tag which currently contains <c:forEach> inside the latter. No use.

According to what I know of <c:forEach tags>, after this:


"userVO" is my bean variable filled with new bean object in every iteration. So, my logic suggests that:
userVO of problematic code is equivalent to currUserVO["1"] of the lower, correct code. And hence i merrily am trying to access the property by suffixing a dot <property name> to it. But it does not work and all I see is a blank page.
Please help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65542
110
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rajat Sharmanaive wrote:Please assume:
1. Collection is correctly session scoped.
2. All properties are valid.

We cannot make these assumptions. SHow us the code where this is set up. The fact that you have to use a string "1" to access the collection (as in ${sessionScope.currUserVO["1"].usrId}
) is suspect.
 
Rajat Sharmanaive
Ranch Hand
Posts: 41
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear

Sorry for inadvertently consuming your precious time. I did mark the question as resolved. If there is anything else that should be done in order to prevent people from spending their time on something that has been figured out, please enlighten. I am new here.

The mistake that kept me thinking (and trying weird stuff) for 48 hrs was a simple capitalization problem.
while setting up the attribute, it was currUserVO (which is why "${sessionScope.currUserVO["1"].usrId}" works). In the problematic code, i was accessing it as:

Never knew a small 16 byte character is capable of all this.
In hindsight, the assumptions were right. As for the syntax where I use string as the index of list, it was suggested in the K&B book that a string index is coerced to an int for arrays and lists. Was just trying that, do not intend to use it as a standard practise.

Thanks
 
Message for you sir! I think it is a tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!