• Post Reply Bookmark Topic Watch Topic
  • New Topic

initializing Vector object via setProperty tag

 
Mike Ottinger
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • 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
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65528
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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
  • 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
Author and ninkuma
Marshal
Posts: 65528
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!