This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
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

Dispatcher Action doubt.

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am having two JSP's one for adding and another editing a customer details. My Requirement is such that I can have one extra field in Edit jsp where as its not present in add JSp.
Here I want to use Single Action So I have created an action which subclasses DispatchAction.
I am also using Struts validator which will redirect the request to a page base on "input" attribute value from struts-config.xml.
Since my add and edit jsp's are different, I can't give a common jsp in the input attribute.
Please suggest whether I can handle this problem.
 
tumbleweed and gunslinger
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not much to go on, but here's a try:
You should be populating your form bean in the action for the edit, you can re-use the same JSP, just have a logic:equal tag determine if the extra field is needed. If yes, then show it, otherwise, assume it's an add.
I'll also assume you can use the same logic to determine what method to post to in your dispatchaction, unless you are using some sort of javascript based on a link or button click.
I've done this many times using the same JSP for both add and edit processes. Only if they vary a lot will I have two seperate JSP files.
Personally, I do not like a lot of "logic" type statements in forms just to determine add/edit state, what fields to show, hide, enable or disable.
IMO, it's just easier to read and understand if it gets too complex to have seperate files. A field or label here and there, no problem.
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I dont think so its a big deal.There is no need to use different jsps..u can use the same JSP but u will be knowing whether u r performing add/edit depending on some parameter...hence u can add a logic tag in ur jsp to display the extra field...........
r else assume that u dont know whether u r performing add/edit then u can include an additional field which is of type String(intialse it to "") ,and generate on fly the Html thing and even the value for this field in the edit logic generate that entire extra field on fly and in ur jsp say <bean:write property="formbeanattribute/>
If its add it will defaultly dispay "" else in edit case it will display whatever u had generated in ur action class for edit
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic