I have had very little luck with the few posts I have put on these forums with all being ignored in favour of the post just above mine that askes for the umpteenth time how should I map my db to objects. And out come the hibernate, ejb, and jdo boys to battle again in long trail thats been done many times before. But here goes anyway:
I am currently making a system that has a struts/jsp views front end that talks to some middle tier.
I have built systems before with struts and find it quiet easy to work with, but a bit verbose. But I like it none the less.
I have a problem that i have previously come across before, and that I've made workarounds for, but was hoping this time out that I could be directed to a more cleaner way of doing it. I suspect that previously I have made a work around for a problem that is already delt within the
Problem is pretty standard stuff
I have an edit object action, action is passed id through actionform, action gets object passes it to jsp (normal via session). ACtion forwards to jsp.
Jps creates html form based on object it was passed, using struts tags.
CLick html submit, passes updateform to updateaction, which calls business method.
All very basic.
What if object that is being updated has a nested object that it can also update. So i want
user to be eable to pass an updated nestedobject_id to the form and let action update. Thats grand extra form value.
But instead of manually entering the value, I want user to click on a link that shows uplist of current nestedobjects in system and allows him to
choose one, and when he does return back to updating jsp form, where nestedobjec_id is set to what he chose. And other edited form fields
are not reset.
So that link will go to getAllnestObject action which forwards to jsp that dispalys them all (with radio button form) lets say.
Is there a neat way to do this sort of flow control, besides dirty putting values in httpsession map etc etc that is not obvious to other developers. This is where struts seems to break down for me, I end up having to write PrepareUpdate actions.
By the way this is not a please do my homework or my job kinda post, this is sort of thing that I come across alot with struts and its not my
area of expertise. I've just used the bare amount that I've needed.
It seems you explained more solution than the real problem
You seem to be assuming the readers are aware of your previous problem and the work around you used.
Please write the exact problem you are facing. Write only the server side issue you are facing.
Hi, sorry ya i was a bit too specific about might own problem there. My main question is
I have a jsp with a form (this has been loaded with some data from an action).
User edits form, but can also click on link that goes to some action gets some data and displays a second jsp view, where user can choose some item (e.g. list of nicknames) and then once selected be rooted back to original form where his editing is still there, now along with the selection he made in second jsp page.
Did i explain that ok, See i could display everything on one jsp page with form and the selection list. But i dont want to have to get all the information needed in the action everytime a user does some editing on this object, reason being well its a lot of information to retrieve from server (this list of nicknames lets say) and 90% of the time the user will just be editing a simple string value and not be interested in resassigning the nickname value from the serverside list of valid nicknamest to this object.
So in the face of code reuse (other editing objects might want to use this assign nickname action + jspview), and in keeping it neat (on need to overpower view with huge nickname list if user only wants to edit some arbitary string attribute), and also performance (dont want to get all possible data everytime, because more than likely as project grows, there will be other possible lists that user might need to select from, like occupations.) and if user was to be edited proceeding action would need to do server side calls getAllOccupations getAllNicknames, getAllAnimals etc etc etc.
Forgot to sum up.
So inconlcusion, how do i do the routing back from the second jsp to the edited first jsp.
1)html doedit link ->passes id to form.
2)Action gets id from form calls server, getsObject. adds it to sesssion. forwards to jspOne
3)jspOne displays bean value in form.
4)user fills in some data in form.
5)user decides to edit nickname, clicks on selectnickname link
6)link is routeed to GetNicknameAction, getsAllNicksnames from server, adds to session, forwards to jspTwo
7)jspTwo displays list of nicknames in form or as html:links, user selects one he wants.
8)???? Now at this point, is it possible to be routed back to step 4/5 where jspOne is now updated with nickname selection.
9)Then user can submit jspOne form, and the updateObjectAction will be executed.
Any help on step 8 will be much appreciated.
I understood this as a state issue.
You want to maintain the preloaded
data of page1.
Page1 has let say 2 links submit-fetch.
on click of fetch it opens page2.
And at the end of operation on page 2 you want
page 1 data to be modified with page2 changes.
I would have gone for page2 as popup and use a callback to page1 to add/modify few fields.
if you dont want roundtrip of parameters or use session.
Hope that helps
What did you manage to do eventually?
I have a situation perhpahs is similar to yours:
I have 1 action which has 2 forwards, the forward1 returns to the same page and the forward2 (I want to) pops up a new windows with a jsp. My action class inherits from LookupDispatchAction. My questions are:
1. What struts tag can I use to popup a new window?
2. Any alternative ways to do this?