Topic
  • 2 replies
  • Latest Post - ‏2013-05-31T14:56:18Z by vikashgupta
vikashgupta
vikashgupta
74 Posts

Pinned topic Custom Login Portlet in WEF

‏2013-05-28T16:12:10Z |

Hi,

I am trying to create a custom login portlet in WEF, so i have to lookup JNDI for portal login service. As in java portlet we do this lookups in init() method and then call the login method from performedAction. Similarly in WEF, i am trying to lookup for this JNDI from a method written in java class and connected with LJO and to replicate init feature i am calling this function on "System:OnWebAppLoad" event.

For testing purpose to check that this function is called once in portlet life cycle, i put some system outs. I deployed this war, and created portal anonymous page and placed my custom login portlet in this page. Now when i am accessing this page first time, system out prints. But when i am going to another portal page and coming back to my page, system out prints again.

As i did this print on webAppload, it sholud not print again. because i think webAppload first time when portlet access.

Please need help to find out what i am missing. I am attaching my archive for reference.

Thanks

 

Attachments

Updated on 2013-05-28T16:22:06Z at 2013-05-28T16:22:06Z by vikashgupta
  • mburati
    mburati
    2568 Posts
    ACCEPTED ANSWER

    Re: Custom Login Portlet in WEF

    ‏2013-05-29T02:25:16Z  

    By default portal does not create sessions for anonymous users (those not yet logged in).

    WEF portlets typically require sessions to maintain state.  If you need to use WEF portlets on anonymous portal pages, then you'll need to enable anonymous sessions  via portal configuration.

    Since the code you're referring to is JAVA, you may wish to implement the accessor as a Java singleton pattern rather than relying on webapp load to initialize it.   You can still access it from a webapp load handler if you wish, but the code itself may be safer (eg, in case you wish to access it from another portlet with another webapp at some point) if you guarantee via code that it's a singleton.

    .I hope that info helps,

    ..Mike Burati 
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

  • mburati
    mburati
    2568 Posts

    Re: Custom Login Portlet in WEF

    ‏2013-05-29T02:25:16Z  

    By default portal does not create sessions for anonymous users (those not yet logged in).

    WEF portlets typically require sessions to maintain state.  If you need to use WEF portlets on anonymous portal pages, then you'll need to enable anonymous sessions  via portal configuration.

    Since the code you're referring to is JAVA, you may wish to implement the accessor as a Java singleton pattern rather than relying on webapp load to initialize it.   You can still access it from a webapp load handler if you wish, but the code itself may be safer (eg, in case you wish to access it from another portlet with another webapp at some point) if you guarantee via code that it's a singleton.

    .I hope that info helps,

    ..Mike Burati 
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

  • vikashgupta
    vikashgupta
    74 Posts

    Re: Custom Login Portlet in WEF

    ‏2013-05-31T14:56:18Z  
    • mburati
    • ‏2013-05-29T02:25:16Z

    By default portal does not create sessions for anonymous users (those not yet logged in).

    WEF portlets typically require sessions to maintain state.  If you need to use WEF portlets on anonymous portal pages, then you'll need to enable anonymous sessions  via portal configuration.

    Since the code you're referring to is JAVA, you may wish to implement the accessor as a Java singleton pattern rather than relying on webapp load to initialize it.   You can still access it from a webapp load handler if you wish, but the code itself may be safer (eg, in case you wish to access it from another portlet with another webapp at some point) if you guarantee via code that it's a singleton.

    .I hope that info helps,

    ..Mike Burati 
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

    Thanks Mike,

    Crating anonymous session worked, now OnWebappLoad is loading once. 

    In case of login portlet this lookup in webappload is fine and safe, and not required singleton pattern, because i dont have to lookup login service again in another portlet. 

    But this singleton pattern will work in case of lookup of dynacache through portlets. I will use there this concept.

    Thanks for guiding and replying.