• 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

ScopedModelDriven Problems

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

I am trying to achieve what I percieve to be something pretty normal but cant get it to work.

I would like to use one Action Class to search on a database via a Business Tier and return a bunch of data which I populate the Model and can then be used on various different pages.

I would then like to allow the user to go forward and back between all the pages showing different parts of the model data and allow them to update it whilst retaining all of the data on each of the pages visited.

I am using ScopedModelDriven Interface to achieve this but it only works to a point.

In the SearchAction Class when I declare the Model and lookup the database to populate the Model Struts2 doesnt appear to put the Model into the session at this point.

However when I click on the next page it does seem to put everything from that page into the Session and when I move between pages and enter new data it always updates the session and retains the data.

My question is how to I get the original Model from the database loaded into session at the start? I am wondering if it is perhaps a bug with Struts2?

I have found that by implementing ScopedModelDriven the setScopedKey and setModel methods are not called if the Model is declared as "Model m = New Model()" in the Action class, but these methods are called if the model is declated as "Model m;"

Please help



 
Cccccccccc Pppppppppppp
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One other thing ive noticed is that when you are using ModelDriven or ScopedModelDriven as soon as you create a new version of the Model() the code stops executing the rest of the interceptors.

e.g. If you implement Preparable and ScopedModelDriven

Ive tried putting the new Model() into various mthods in the stack and as soon as the code exectues this line and jumps out and doesnt execture any other methods.

Is this a bug with Struts 2?

Im basically having to go back to Struts 1 way of doing things and use the HttpSession to hold my model and move it around that way.

 
reply
    Bookmark Topic Watch Topic
  • New Topic