Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Portlet form data persistence

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Jay Kv
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic