0

I tried to implement flash in JSF. It's working well if I have to transfer Java object between pages in one session. But I have a spacial case which I need to solve.

I have a submit form where user enters personal data. Then he opens second page which is used to open payment gateway(paypal) page. When the payment is applied Paypal redirects the user back to the web site in a new web page.

I need some way to transfer the Java object data between the first and the last page. Is there any solution? I'm using JSF 2.2.6 with Tomcat 8.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
  • 2
    Uhmmm where does the separate session come from? Just store it IN the session, or add it as request parameters to the return url that you provide to paypal (if you use one and it is safe security wise) – Kukeltje Aug 28 '15 at 11:36
  • [Storing object in the session](http://stackoverflow.com/questions/7480325/how-to-save-an-object-into-jsf-session). – Omar Sep 03 '15 at 14:55
  • I cannot 'flag' it as a duplicate... hence a link-only answer: https://stackoverflow.com/questions/7991771/integrate-paypal-in-web-application-using-java And encode your parameter in the RETURNURL request param... – Kukeltje Sep 01 '15 at 09:05

1 Answers1

1

I guess the redirect of paypal to your site create a new session, if this is the case all you have to do is create a DTO object and store into BD with session ID using serialization Java Serializable Object to Byte Array

But if paypal call on same session all you got to do is get the object from the session like this

FacesContext facesContext = getFaceContext();
Application app = facesContext.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = facesContext.getELContext();
ExternalContext externalContext = facesContext.getExternalContext();
HttpSession session = (HttpSession) externalContext.getSession(true);
session.setMaxInactiveInterval(-1);
ValueExpression valueExp = elFactory.createValueExpression(elContext, expression, Object.class);
YourBean yourBean = (YourBean) valueExp.getValue("#{yourBean}");

The scope of this bean it must be @SessionScoped

Community
  • 1
  • 1
Rendón
  • 300
  • 1
  • 7