Clarity

  • 1.  HTML Portlet Hello World Example

    Posted 02-25-2016 12:22 PM

    Hello -

    Does anyone have a working HTML Portlet that performs a simple task that displays data from a query and also performs a XOG Update for a field or two?  Maybe - change project status (from INV_INVESTMENTS).  Hardcoding the project ID is fine for this purpose.  Our main goal is to show some of our users that it is possible, rather than how fancy it can be.  From reading posts in the community and studying some HTML5 tutorials, I know this won't be trvial and would require JavaScript skills and that's OK.  So far, however, I have only been able to find some very complex examples with a high reliance on .css as well, which makes it hard to pick through what is happening for a beginner.

     

    Thanks in advance,

    John



  • 2.  Re: HTML Portlet Hello World Example

    Posted 03-21-2016 01:28 PM

    I don't have an answer ; but there is something here  https://communities.ca.com/message/100577506#comment-100577506

     

    (from here Displaying Database Content in HTML Portlets )



  • 3.  Re: HTML Portlet Hello World Example

    Posted 03-21-2016 04:41 PM

    Some of these techniques can be hindered by settings in the CSA now, in particular this setting on the Application properties tab:

     

     

    "Use HttpOnly Session Cookie"

     

    As the setting explains, using it will inhibit the retrieval of the user's session ID from within the javascript on the HTML portlet, which is what those other techniques were using in order to fetch data via XOG without having to request a secondary login first.

     

    Just something to be aware of.



  • 4.  Re: HTML Portlet Hello World Example

    Posted 03-21-2016 05:07 PM

    Hi David,

    Thanks for responding.  That was actually the thread that got me to thinking we could do a lot more than just display data.  I was hoping to develop pages that mash data together from different objects but also provide update function's from the same page - something I believe is impossible using standard portlet construction.  So the key is the ability to update using XOG triggered by javascript functions.  I know I am trying to shortcut some research, but I thought I'd give it a try. 

     

    Rgds,

    John



  • 5.  Re: HTML Portlet Hello World Example

    Posted 03-21-2016 05:22 PM

    So the only way (On Demand 14.3) that I have been able to get this to work is to place a simple html code block that contains JavaScript code that looks up the sessionID and then does a url redirect to my external system passing along the session ID.

    Here is a simple example to post a set of urls with the sessionID.

     

    Which renders:

     

     

    The HTML code:

     

    <div>
    <a class="seCheckBook" href="https://www.example.com/search?q=" target="_blank">CheckBook 1 = </a> <br>
    <a class="seCheckBook" href="https://www.example.com/search?q=" target="_blank">CheckBook 2 = </a> <br>
    <a class="seCheckBook" href="https://www.example.com/search?q=" target="_blank">CheckBook 3 = </a> <br>
    <a class="seCheckBook" href="https://www.example.com/search?q=" target="_blank">CheckBook 4 = </a> <br>
    </div>
    <script>
    var i = 0;
    var href = "";
    var sessionId = "";
    var cookies = document.cookie.split(';');
    var cookie = "";
    
    var value = "; " + document.cookie;
    var parts = value.split("; sessionId=");
    if (parts.length == 2) sessionId = parts.pop().split(";").shift();
    
    var links = document.getElementsByClassName("seCheckBook");
    for (i = 0; i < links.length; i++) {
        href = links[i].getAttribute("href");
        href = href + sessionId;
        links[i].setAttribute("href", href);
        links[i].innerHTML = links[i].innerHTML + sessionId;
    }
    </script>
    

     

    The XSS settings as Nick has pointed out make doing anything interesting in On Demand pretty hard.

     

    For On Premise, it is way easier as most of the XSS protection are centered around the domain.  So I would just setup a new web app on the PPM server listening on a different port.

     

    V/r,

    Gene



  • 6.  Re: HTML Portlet Hello World Example

    Posted 02-23-2017 09:12 AM

    how can you access sessionID cookie from JS if it is set to httpOnly? I just tried the script myself on CA PPM 14.3 On-Demand and it does work as described earlier :/ 



  • 7.  Re: HTML Portlet Hello World Example

    Posted 02-23-2017 06:44 PM

    It's just in a different place, you can still access from javascript. I have using this for over a year now with no issues. My clients are all on demand.

    window.clarity.session.sessionId


  • 8.  Re: HTML Portlet Hello World Example

    Posted 02-24-2017 05:12 AM

    nice! Finally, the solution that worked for me. Thank you.