Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Struts help, logic:notEqual and ArrayList size()

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I have a html:select box which is populated by an ArrayList stored in the request. The first option in the select box is text saying 'Select Option...', I have coded this as follows:



This works perfectly, but our customer has now decided that if only one option is available, it should automatically be selected and the 'Select Option...' text should not appear in the dropdown.

I thought this would be a fairly simple thing to implement but am having difficulties. I tried using a <logic:notEqual> tag as shown below:



But of course this doesn't work, I get a NoSuchMethodException: Unknow property size.

I've tried several other ideas but all to no avail. I can't imagine this is a difficult thing to do but have to admit defeat.

Somebody has suggested struts expression language, which I have never used. Can anybody help?

Thanks in advance,
Feargal
 
Feargal Egan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, original post without smilies!


Hi all,

I have a html:select box which is populated by an ArrayList stored in the request. The first option in the select box is text saying 'Select Option...', I have coded this as follows:



This works perfectly, but our customer has now decided that if only one option is available, it should automatically be selected and the 'Select Option...' text should not appear in the dropdown.

I thought this would be a fairly simple thing to implement but am having difficulties. I tried using a <logic:notEqual> tag as shown below:



But of course this doesn't work, I get a NoSuchMethodException: Unknow property size.

I've tried several other ideas but all to no avail. I can't imagine this is a difficult thing to do but have to admit defeat.

Somebody has suggested struts expression language, which I have never used. Can anybody help?

Thanks in advance,
Feargal
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Struts EL is similar to JSTL EL, do you know JSTL? If so, you will find that there is only a small difference between them.

Otherwise, here is a simple tutorial about Struts EL:
http://javaboutique.internet.com/tutorials/Struts_EL/

Nick
 
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I get a NoSuchMethodException: Unknow property size.



You should have a method getSize() .
 
Feargal Egan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You should have a method getSize()



How? Sub class ArrayList and add a getSize() method? Seems a bit excessive for what looks like a trivial problem.

I'll investigate the Struts-EL tutorial.

Thanks for your help!
 
David Ulicny
Ranch Hand
Posts: 724
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Of course not subclass ArrayList.

taskList is ArrayList? Just wrap it, and write the method getSize()
 
Feargal Egan
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I misunderstood!

Wrapping it will work fine I think, thanks!
 
Do not threaten THIS beaver! Not even with this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic