aspose file tools*
The moose likes Portals and Portlets and the fly likes Portlet form data persistence Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Portlet form data persistence" Watch "Portlet form data persistence" New topic
Author

Portlet form data persistence

Jay Kv
Greenhorn

Joined: Apr 06, 2006
Posts: 5
Hi,

I am new to portlet development and have this problem:
There are 2 portlets on the portal in the same page. One is an email
portlet, and the other is an email-address lookup portlet. If the user
types up the email in the email portlet and looks up email address in
the other portlet, the typed up email is lost due to the page refresh.

Is there a way to preserve the typed up email ? This sounds like a should-be-common problem to me. And it doesn't seem like there are any facilities provided at the infrastructure level by any of the portal vendors.

Thanks in advance for any help on this.

Jay
Nit Sharma
Greenhorn

Joined: Jan 27, 2006
Posts: 9
Hello Jay,

How are you writing your portlets?Are you using Struts framework or simply writing plain JSR 168 portlets.Because the problem you stated should not exsist if you use proper mechanism to hold client data in some sort of java bean.


Regards<br />Nitin<br /> <br />Sun Certified Java programmer <br />Sun Certified Web Component Developer(SCWCD)<br />Sun Certified Enterprise Architect(SCEA)<br />IBM Certified Solution Developer WebSphere Portal V5.1
Jay Kv
Greenhorn

Joined: Apr 06, 2006
Posts: 5
Hi Nitin,

Thanks for your reply. We are using an in-house MVC framework with IBM Portlet APIs. In the problem scenario I explained, if you think of the portal page as one big HTML page, there will be 2 forms, one for the email related contents and one for the address-lookup. So when you hit submit on the address-lookup form to perform a search, how will the data in the email form be stored in the beans ? As far I understand struts, it stores the form data into form-beans automatically as you mentioned, but ONLY for the form that is submitted. Could you please elaborate on what you said ?

Thanks,
Jay
Nit Sharma
Greenhorn

Joined: Jan 27, 2006
Posts: 9
Hello Jay,
My understanding is that you have two portlets.One Email and other address look up, as you said in your first post.Now i guess the functionality is that these two potlets are talking to each other otherwise you will not enter email on email portlet and do a lookup of address in address portlet.
you enter email on first and submit.
address portlet displays you the address.

if this is the scenario than there is no reason that you loose your state on email portlet as you are submitting the form of email portlet.

May be I am not able to understand your requirement.
Jay Kv
Greenhorn

Joined: Apr 06, 2006
Posts: 5
Hi Nitin,

Sorry if I didn't explain well. Let me rephrase the problem:

I have more than one portlet on a portal page. User fills a form in one of the portlets (say, portlet A). Before submitting that form, he submits a form/click a link in another portlet (say, portlet B). When the portal page reloads, the data typed up by the user in portlet A is lost.

How can I preserve the form data in portlet A ?

Jay
Nit Sharma
Greenhorn

Joined: Jan 27, 2006
Posts: 9
Hello Jay,
Now it looks very strange requirement in terms of Portal development.
It looks you want to keep the client data on portletA intact while portlet B goes through action phase.
The only solution i can think of is that somehow you dont show the user that portlet A is getting submitted while you are entring data in Portlet A.Infact you will be calling the server side while entering data on portletA.This can be achieved by AJAX.Which is nothing but passing state to server through JavaScript.

Use Ajax to submit form state to server.
Jay Kv
Greenhorn

Joined: Apr 06, 2006
Posts: 5
Hi Nitin,

I know well and had been arguing myself with the team that this is very well a requirement that does not fit with the portal technology. But you know sometimes how the business needs can be

Thanks for throwing in the idea of AJAX, I will do some research on the same. The only issue I am concered about off the top of my head is the performance hit on the server. But I guess if you badly need some feature something else needs to take the hit!

Thanks,
Jay
Nit Sharma
Greenhorn

Joined: Jan 27, 2006
Posts: 9
Hello Jay,
performance will not be an issue while using Ajax.If form is big on portlet A than you can submit Portlet B through AJAX and will still be able to keep the whole page not refreshed.
Jay Kv
Greenhorn

Joined: Apr 06, 2006
Posts: 5
Hi Nitin,

I tried Ajax and it solves the problem. This is what I tried:

For the form fields, I added an onblur event handler. This handler script first checks if the user has changed the value of the field. If yes, then it POSTs that field, its value, and the form bean name to a servlet that is in the same web application as the portlet. The servlet then extracts the form bean object from session based on the form bean name that was POSTed and updates the specific field using reflection apis.

Thanks again for throwing in this idea.

Regards,
Jayanand
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Portlet form data persistence