Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to combine jsp pages?

 
Ramya Sree Kalagiri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I'm using spring portlet MVC, and Liferay 6.1 CE. I have 3 jsp pages for example addDetails.jsp, editDetails.jsp and viewDetails.jsp, I would like to use single jsp page for all the 3 actions(viewing, editing and adding details) instead of 3 jsp pages. Will view and edit mode of portlet will help to achieve this? Please help me. Thanks in advance
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In general, this is done by passing a parameter to the jsp to determine how to display the page DOM elements.

For example, passing a "mode" parameter ('view', 'update') to the jsp would allow for this.

If "mode" == "view" then
display readonly..
else if "mode"== "update"
display form elements to save the data.
end
 
Ramya Sree Kalagiri
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Philip,
Thank you for the reply. I implemented this idea already and it is working fine, bt I would like to use view and edit mode of portlet. Isn't it a better idea to use view and edit modes instead of using the parameters. I'm allways confused with difference between view and edit mode, can you explain me briefly?
 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ramya,
You certainly can use the edit or view mode of the portlet for this purpose. At a high level, in your Portlet class you will have a method to implement doEdit(...) just as you have doView(...), and doAction(). When you define youre link to edit the record in the view, you'll need to specify in the link to use "doEdit". Of course, these method names are only a high-level view and vary based on your portlet container specification/implementation (JSR 168, JSR 286, IBM, etc..). Hope that helps.

Cheers,
Philip
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic