Redirect from Portlet_A to Portle_B on a different page - Websphere

This is a discussion on Redirect from Portlet_A to Portle_B on a different page - Websphere ; I have some business logic that requires the user to enter data on Page_A within Portlet_A and if that data meets certain criteria, I then need to do an actionResponse.redirect(generatedURL) to display Portlet_B which resides on the page "Page_B". I ...

+ Reply to Thread
Results 1 to 20 of 20

Thread: Redirect from Portlet_A to Portle_B on a different page

  1. Redirect from Portlet_A to Portle_B on a different page

    I have some business logic that requires the user to enter data on Page_A within Portlet_A and if that data meets certain criteria, I then need to do an actionResponse.redirect(generatedURL) to display Portlet_B which resides on the page "Page_B".

    I am NOT transferring any data, I am simply doing a redirect.

    I read the following article, which seemed like it would be able to help me, but I am not being redirected to Page_B:

    http://www-01.ibm.com/support/docvie...id=swg21265900

    It almost seems like the article above is only to generate a URL that a user will click on from within a JSP, but that is not what I am trying to do. I want to do a redirect.

    Here is what I have in Portlet_A:

    {code}
    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException
    {
    ...
    String generatedURL = PortletURLHelper.generateUrl("Page_B","Portlet_B",null, false, actionRequest, actionResponse);

    actionResponse.sendRedirect(selfcareUrl);
    ...
    }
    {code}

    The end result is a generated URL, but it takes me back to the home page, and not to Page_B. I have confirmed that "Page_B" and "Portlet_B" unique names are accurate. (If they were not accurate, then I would receive an Exception)

    Any suggestions? Am I going about this the wrong way?

    Thanks,
    _Sean

  2. Re: Redirect from Portlet_A to Portle_B on a different page

    I have also tried to use the OffLineURLHelper to no avail:

    {code}
    MyServerContext serverContext = new MyServerContext(
    request.getServerName(), request.getServerPort()+""
    );

    String targetURLStr = OffLineURLHelper.generateUrl(
    "Page_B", "Portlet_B",
    null, serverContext, false);
    {code}

    I have also tried to set the boolean parameter to true as well (generate a private page), but that did not work either.

    Am I going at this the wrong way?

    Thanks,
    _Sean

  3. Re: Redirect from Portlet_A to Portle_B on a different page

    Hi Sean,

    The code you are trying should work.

    make sure following

    import of PortletURLHelper should be *com.ibm.wps.l2.urlspihelper.portletrequest.Portle tURLHelper*

    portlet B unique name should be created using *xmlAccess only*.

    and the jar file you are referring to should be *wp.l2.url.helper.jar*

    thanks..
    **
    *[ExtremePortal|http://ExtremePortal.blogspot.com]*

  4. Re: Redirect from Portlet_A to Portle_B on a different page

    Custom Unique Names.

    Is this the same as xmlAccess?

    Also, via another flow, I can get to Page_B.Portlet_B within my production environment. From here, my URL looks like:

    {code}
    https://www.mycompany.com/wps/myport...LUDlGUjEwMDA!/
    {code}

    While in my test environment, the generated URL to Page_B.Portlet_B (with the code above) looks like:

    {code}
    http://wwwtest.mycompany.com:443/wps...6BdmBigCKihWQ/
    {code}

    Obviously they should not be identical b/c they are in 2 different environments, but I find it interesting that the Production version is https and that it is much longer then the generated URL in test.

    Would this just be due to the different environments or is it an indication that I am doing something wrong?

    Thanks,
    Sean

  5. Re: Redirect from Portlet_A to Portle_B on a different page

    After looking at this some more, the URL issue is apples and oranges.

    In reality, I am trying to redirect to Page_B.Portlet_B from my Login Portlet (aka Page_A.Portlet_A above).

    (Portlet_B is my custom Selfcare Portlet, and the only
    portlet on Page_B)

    From the Login portlet, I authenticate the user, and then redirect if they need to reset their password.

    Does this change anything?

  6. Re: Redirect from Portlet_A to Portle_B on a different page

    you can assign unique name to page from portal admin but assigning unique name to portlet must be done using xml access only..

    have a look at my article on *[Assigning unique name to portlet and page|http://extremeportal.blogspot.com/20...let-and.html]*

    after doing this, you are good to go...

    hope that helps..
    thanks
    **
    *[Extreme Portal|http://ExtremePortal.blogspot.com]*

  7. Re: Redirect from Portlet_A to Portle_B on a different page

    Maybe I am going at this the wrong way then. On my custom Selfcare Page, I have only the one Custom Selfcare Portlet.

    If I am going to a page that has only 1 portlet, do I really need to generate a URL to that specific portlet?

    Is there an easier way to just generate a URL to a particular page?

    Thanks,
    Sean

  8. Re: Redirect from Portlet_A to Portle_B on a different page

    well, generating a url to portlet should be done two cases
    a) if you have more than one portlet on a page and you want to hit perticualar portlet.
    b) if you want to pass parameter to a portlet on the page.

    well in your case, that should also work.
    did you try creating portlet(custom selfcare) uniquename using xmlaccess and then redirecting to the generated url?

    thanks..
    **
    *[Extreme Portal|http://ExtremePortal.blogspot.com]*

  9. Re: Redirect from Portlet_A to Portle_B on a different page

    Portlets and updating the name.

    What is the difference here?

    Anyway, even after I have updated the Portlet unique name via XML Access it does not work.

    The URL generated from different methods are below:

    PortletURLHelper.generateUrl(...)
    {code}
    /wps/portal/!ut/p/c1/04_SB8K8xLLM9MSSzPy8xBz9CP0os3gDSwtffycLY0ODUGdnAy MnbzMvSyMfYwsDE_1I_ShzJHkTR1cDTxOTgGALLy8jA29j_YLs QEUA2cfztw!!/
    {code}

    Note that the above example does not generate "wps/myportal" which I would expect it to. Also notice that it does not provide the full URL, but everything after the base URL. It is also not https like I would expect and takes me back to the Home Page (just like any random gibberish would post the base url).

    OffLineURLHelper.generateUrl(...)
    {code}
    http://wwwtest.mycompany.com:443/wps...sQEUA2cfztw!!/
    {code}

    Note that this code does generate the entire URL, and it uses "wps/myportal", but it is still not https. Also, when it redirects to this URL, I get a popup to download a file named "seS78VuK.part". I download it and open it and it is a few characters of serialized data. The file name changes every time, but the extension is always ".part"

    Any other suggestions?

    Thanks,
    Sean

  10. Re: Redirect from Portlet_A to Portle_B on a different page

    I have also thought to try and implement this functionality as a filter instead of a redirect within the portlet.

    I saw another conversation you had here: http://groups.google.com/group/ibm.s...b8fcecef2e6aa4

    Which helped, but I could not get the request to go through the filter, even though I set it up according to your blog post (or at least I think I did).

    Is this another viable option to solve my problem?

    Because I am thinking about heading down this path due to the fact that the URLs being generated are not accurate from within my portlet, and I wonder if it is because I am somehow not authenticated yet. (Even though I am authenticated before doing the redirect within my code)

    Thanks,
    Sean

  11. Re: Redirect from Portlet_A to Portle_B on a different page

    I am beginning to wonder if the issue lies in that my code above "PortletURLHelper.generateUrl(...)" is called from a Portlet that extends GenericPortlet (a standard JSR-168 portlet) and the Portlet that I am calling is a Struts Portlet.

    In the IBM documentation at: http://www-01.ibm.com/support/docvie...id=swg21265900

    it states that "This is only for making URLs between standard API portlets." Now, I do not know enough about Portlets yet to know whether or not a Struts Portlet is considered a "standard API portlet".

    Could this be a problem?

  12. Re: Redirect from Portlet_A to Portle_B on a different page

    ok, let me ask you few things here

    you are saying
    "From the Login portlet, I authenticate the user, and then redirect if they need to reset their password"
    here, where does user decide that they want to reset their password?

    do you have something like this

    login portlet has something like this in UI...

    userid - textbox
    password - textbox
    reset pass - check box
    login button

    user comes, enter his uid and password and if he checks reset password check box then you authenticate user and redirect to selfcare portlet.
    when user doesn't check the reset password check box then you just authenticate the user and he just logged in to portal.

    did i understandd correctly?


    thanks..
    **
    *[Extreme Portal|http://ExtremePortal.blogspot.com]* At GMAIL DOT COM

  13. Re: Redirect from Portlet_A to Portle_B on a different page

    You're close, but in this scenario the user is sent to Selfcare because a resetPwdFlag = true on their ldap account.


    The user does not elect to go into Selfcare, the system redirects them there because of the aforementioned logic.

  14. Re: Redirect from Portlet_A to Portle_B on a different page

    ok got you..
    so user will be sent to selfcare portlet only when *resetPwdFlag* found to be *true* for that user else they will be logged into to portal. is that right?

    this is going to be bit tricky..

    here is how you can achieve this..

    a)Implement AuthenticationFilter
    b)in filter after authentication, retrieve resetPwdFlag value for that user using PUMA.
    c)if this value found to be true, redirect user to self care portlet else just logged him in to portal.

    hope that helps...

    thanks..
    **
    *[Extreme Portal|http://ExtremePortal.blogspot.com]* AT GMAIL DOT COM

  15. Re: Redirect from Portlet_A to Portle_B on a different page

    I started down that road yesterday just to try something different, and I have a few issues with that approach.

    1) In order to redirect to the Selfcare Page, I am still going to have to generate the URL to the Selfcare Page. Granted, I will be using the ServletHelper, and not the PortletHelper, so maybe that will make some sort of difference within the ExplicitFilter

    2) I have put together an ExcplicitLogin filter, and it is not being called. It is being initialized (I see the logging output from my init() method), but the login() method is not called. (note, I do not have the code in front of me, but whatever the method is that does t he work is not called)

    Do you have any insight into the issues above? Am I going down the right path?

    Thanks again for the help!

    _Sean

  16. Re: Redirect from Portlet_A to Portle_B on a different page

    1) yes that will require a code change in your class which is implementing ExplicitLoginFilter
    you can also redirect to selfcare page without generation url to selfcare page,
    try doing following code after authentication in filter,
    portalLoginContext.setRedirectURL("wps/portal/SelfcarePage"); ( though i am note about this..)

    2) LoginService.login() method makes a call to login method of filter and there authentication happens....
    so you should have LoginService.login call in your custom login portlet.

    thanks..
    **
    *[Extreme Portal|http://ExtremePortal.blogspot.com]*

  17. Re: Redirect from Portlet_A to Portle_B on a different page

    Custom Properties

    login.explicit.filterchain = com.mclane.filters.LoginToSelfcareFilter
    {code}

    I put the class com.mclane.filters.LoginToSelfcareFilter in a jar file, which is in the /shared/apps dir

    I know that the com.mclane.filters.LoginToSelfcareFilter is being initialized b/c I see the output of init() in SystemOut.log file. However, the login() method is never called.

    Does anything look wrong from what I have put together so far? Am I using the proper Auth class and extending the proper ExplicitLoginFilter?

    Thanks,
    Sean

  18. Re: Redirect from Portlet_A to Portle_B on a different page

    WPS 6.0 and above versions provides a LoginService for authentication. Use LoginService and not AuthenticationPortletService .

    lookup the LoginHome in init method of portlet

    *javax.naming.Context ctx = new javax.naming.InitialContext();*
    *PortletServiceHome psh = (PortletServiceHome) ctx.lookup(LoginHome.JNDI_NAME);*
    *loginHome = (LoginHome) psh.getPortletService(LoginHome.class);*

    in processAction, get loginService from LoginHome and call login

    *LoginService loginService = (LoginService) loginHome.getLoginService(request, response);*
    *loginService.login(userId, password.toCharArray(), contextMap, null);*

    This loginService.login makes a call to login of filter.

    thanks..
    **
    *[Extreme Portal|http://ExtremePortal.blogspot.com]*

  19. Re: Redirect from Portlet_A to Portle_B on a different page

    Sorry for my delayed response, I have been out of town the past week or so.

    I have integrated the LoginHome and LoginService into my custom login portlet. However, the flow still does not go into my Filter.

    The only thing I changed was that I pass in an Empty Map instead of your referenced "contextMap".

    {code}
    loginService.login(userId, password.toCharArray(), Collections.EMPTY_MAP, null);
    {code}

    What is your contextMap, and should I be using that?

    My setup for "registering" my filter (login.explicit.filterchain) via the "WP AuthenticationService" is still consistent with what I have above.

    Any other suggestions?

    Thanks,
    Sean

  20. Re: Redirect from Portlet_A to Portle_B on a different page

    contexMap should have at least following key and value might change as per your env....new Boolean(false) should be fine in your case.

    here you go...

    *Map contextMap = new HashMap();*
    *contextMap.put(LoginService.DO_RESUME_SESSION_KEY , new Boolean(false));*

    *LoginService loginService = (LoginService) loginHome.getLoginService(request, response);*

    *loginService.login(userId, password.toCharArray(), contextMap, null);*

    this should now call login method of filter class.

    thanks..
    **
    *[Extreme Portal|http://ExtremePortal.blogspot.com]*

+ Reply to Thread