• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

initializing Vector object via setProperty tag

 
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Folks,

I'm fairly new to JSP and have a little problem that I'm sure people have dealt with before. I'm simply trying to initialize a vector in a bean which will then later on have its contents displayed via a custom tag designed to iterate. I have a bean called ModelBean that represents the connection to a data model(ontology). In my index.jsp file I grab a reference to it using your standard useBean tag. I then want to retrieve a subset of data from the model and store this in a vector as a property to the bean. I had luck in intializing the vector in the bean's constructor, but I need to invoke initialization from a separate call because of some other dependancies in retrieving the subset. One thing I tried was making a bogus String property in the model bean called dataSet getting set with <jsp:setProperty id="model" property="dataSet" value="set" /> Then in the setter, setDataSet() I initialize the vector, but all I get with this is an introspection related exception on the page. Will I have to put together a custom tag to do this? Any advice on this is greatly appreciated, thanks
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All of that data pre-processing is far better handled in a servlet which can then pass it along to the JSP page for display. Do yourself a favor and look up the "Model 2" pattern for web applications.
 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was thinking about that as an option. I'm really interested in having this model accessible to other beans and not just jsp pages. I think it's this bean scope that has me hung up...
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want to encapsulate the functionality in a separate bean, that's fine and does nothing to prevent you from using it from a servlet controller.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic