• Dynamic Content - hash parameters

    By Thomas Adrian 1 decade ago

     

    I am using the Dynamic Content control to display different Custom Controls based on the hash.

    Like this in the url  /home.xsp#content=customcontrol

    What I want to do know is to extend the hash to include additional parameters, this way I can perform more tasks within the same custom control and user can bookmark these things

    Like this in the url:/home.xsp#content=customcontrol&id=1234

     

    Currently it is not possible to use parameters after the hash

    so this url will not work with the dynamic content control:/home.xsp#content=customcontrol&id=1234 as the facet key seem to look for anything after "content" 

    </xe:dynamicContent>
    <xp:this.facets>

    <xp:span xp:key="customcontrol">
    <xc:cc1></xc:cc1>
    </xp:span>
    </xp:this.facets>
    </xe:dynamicContent>

     

     

    I hope you understand what I mean.
    

    using the hash to load dynamic content seem to be the way to do stuff on the internet these days (facebook, twitter etc..), so I really hope you continue to add feature to this control.

     

    thanks

    Thomas

     

     

     

     

     

     

     

    • You can use parameters

      By Philippe Riand 1 decade ago

      Look at the dynamic page demo in the demo DB. Accessing a document is done with a url like this:
      http://priand/XPagesExt.nsf/Core_DynamicPage.xsp#content=contact&action=editDocument&documentId=A3A

      The parameters are temporarily pushed into the request map when the facet is constructed, so the existing objects like the data sources can automatically consume them. Calling the method show(facet,params) does exactly the same.

      • help

        By Thomas Adrian 1 decade ago

        Ok, thanks, I must be stupid not to understand this, is there any doucmentation I can read about this?

         

        Question1:

        I do not understand the part where the id and the action sent in to be automatically connected to a data source. can you please explain this. 

        I need to get hold of the parameter values in order to hide stuff based on the parameter, how?

         

        Question2:

        what is show(facet,param) ?

        I get errors when using this methods on both client and server side, what am I missing

         

        Question 3

        I do not understand the difference between using hash or not in the dynamic content control, hash seem to be used regardless if enabled or not.

         

        Question 4:

        when I click the first "edit first contact" link in the demo an ajax call is being made, how does this work, what do I need to do to make this ajax call besides to add the url:

        #content=messages&action=editDocument&documentId=1234

         

        thanks

        Thomas

         

        • Like this

          By Philippe Riand 1 decade ago

          Question1: I do not understand the part where the id and the action sent in to be automatically connected to a data source. can you please explain this. I need to get hold of the parameter values in order to hide stuff based on the parameter, how?

          The data source used parameters from the URL, either the requestMap or the requestParameterMap. This dynamic control temporarily push the arguments to these map, and the data source uses them
          Look at the sample in the DemoDB

           

          Question2: what is show(facet,param) ?

          This is a  server side method - See the demo DB where it is being used.

           

          Question 3: I do not understand the difference between using hash or not in the dynamic content control, hash seem to be used regardless if enabled or not.

          Hash is only used when specified. It is a way foe the user to bookmark a url with the state. Without the hash, it works but the url cannot be bookmarked

           

          Question 4: when I click the first "edit first contact" link in the demo an ajax call is being made, how does this work, what do I need to do to make this ajax call besides to add the url: #content=messages&action=editDocument&documentId=1234 

          The demo database shows the 4 ways for changing the current content, with a client side or a server side piece of code, depending on what you need.

           

    • By Viktor Geiger 8 years ago

      Hi Thomay,

      I think I've the same problem.

      If i try to open dynamic Content context from a bookmarked url it stay's on the default facet.

      MyLink looks like the following:
      http://myserver.mydomain.local/apps/mydatabase.nsf/home.xsp?#content=doc&action=readDocument&documentId=E1AFE14991499D5EC1257EED0037F707

      I've a xpage with dynamic content <xe:dynamicContent …

      and two panel inside

                      <xp:this.facets>
                          <xp:panel xp:key="view" id="panel2">
                              <xc:viewHome id="viewHome1"></xc:viewHome>
                          </xp:panel>
                          <xp:panel xp:key="doc" id="panel3">
                              <xc:formInventory id="formInventory1"></xc:formInventory>
                          </xp:panel>
                      </xp:this.facets>
      
      1. If I load the link after I've switched from “view” to “doc” and back the link works. (Not with a new session)

      2. I've implemented a button to open the dynamic content from the url …. this works, too (better)

      //Start Button Code (the function is a copied snipped from

      Thomas Adrian -> You )

      function getHashUrlVars(){

      var vars = [], hash;
      var hashes = window.location.href.slice(window.location.href.indexOf('#') + 1).split('&amp;');
      for(var i = 0; i < hashes.length; i++)
      {
          hash = hashes[i].split('=');
          vars.push(hash[0]);
          vars[hash[0]] = hash[1];
      }
      return vars;
      

      }

      // if the url is: http://server/home.xsp#content=news&id=123
      // fhe following function return “news”

      getHashUrlVars()[“content”];

      XSP.showContent(“#{id:dynamicContent}“,getHashUrlVars()[“content”],{action:'editDocument',documentId:getHashUrlVars()[“documentId”]})
      //End Button

      1. How do you have solved this? What I'm doing wrong?