Accessing context variables on other pages

So, I am working on building my first Sharepoint App.  The app has 2 pages. The first page is accessible by everyone, and the 2nd page is accessible to managers only. Users submit to HR prospective recruits. The first page stores the submission in a
list in the host_web.  When I load the 2nd page, I need to pull that data.  Likewise, one of the first things I need to do is to get the current and host context.  However, I don't seem to be able to do this on the 2nd page.  It worked
perfectly well on the first page.  Page 2 always gets hung up here:
hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
How do I get this data into page 2?

Hi,
According to your post, my understanding is that you have an issue about get the host web url and app web url.
That’s because the APP url is constructed as below.
http://apps-{UniqueID}.sp2013apps.local/sites/{ParentSiteName}/{AppName}/
And we can use the decodeURLComonent method to get the  host web url and app web url.
However, when we redirect to a new page, the url address has changed, we could not get the host web url and app web url.
As a workaround, we can use the cookie to save the app web url and host web url, then in the page2 to get the cookie value as below.
In page1 to save the app web url and host web url to the cookie.
$.cookie("App Web URL", SPAppWebUrl);
$.cookie("Host Web URL", SPHostUrl);
The page2 to get the cookie value.
alert("App web url===page_2"+$.cookie("App Web URL"));
alert("Host web url===page_2" + $.cookie("Host Web URL"));
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support

Similar Messages

  • Accessing public variables from other classes

    Probably a simple questions, but how can I access a variable from another class. My exact situation is as follows.
    A class called WorldCalender has a variable which is defined: public int hour; (the value is given to it elsewhere).
    I want to access this variable and increase it by one in a subroutine in the class Hour. In this class I have put: WorldCalender.hour++; but it doesn't seem to work. How should I do it?

    don't expose the hour variable at all.
    have a method eg addToHourBy( int hrs )
    Probably a simple questions, but how can I access a
    variable from another class. My exact situation is as
    follows.
    A class called WorldCalender has a variable which is
    defined: public int hour; (the value is given to it
    elsewhere).
    I want to access this variable and increase it by one
    in a subroutine in the class Hour. In this class I
    have put: WorldCalender.hour++; but it doesn't seem to
    work. How should I do it?

  • Retreive int variable from other pages.

    Hi,
    My program is something like this:
    Content.jsp
    <script type="text/javascript">
    function clicked2()
    var x2;
    for (var i = 0; i < form1.radio.length; i++)
    if (form1.radio.checked)
    x2=(form1.radio[i].value );
    document.form2.hiddenTextBox.value = x2;
    </script>
    <%int i=0;
    for(int l=1;l<=(Ress.size()/4);l++){ //Ress is my vector of results
    %>
    <tr>
    <td width="10%">
    <form method="get" name="form1" action="Update.jsp">
    <fieldset>
    <input type="radio" name="radio" value="<%=l%>">
    </fieldset>
    <input type=submit name="submit" value="Update" onclick="clicked2()">
    </form>
    <br><br>
    <form name="form2" method="get" action="content.jsp">
    <input type=submit name="submit" value="Delete" onclick="clicked2()"><br>
    <input type="hidden" name="hiddenTextBox"><br>
    </form>
    <br>
    <% int y2 =0;
    if(request.getParameter("submit") != null){
    y2 =Integer.parseInt(request.getParameter("hiddenTextBox"));
    session.setAttribute("num",new Integer(y2));
    //For deleting data
    String Result="";
    Result=mb1.deleteRow(y2);
    if (Result.trim().toLowerCase().equals("deleted")){
    out.println("Deleted from the database");
    }else{
    out.print(Result);
    }%>
    update.jsp
    <%Integer i1=(Integer) session.getValue("num");
    int i2=Integer.parseInt("num");%>
    <td width="65%">
    <input type=text name="textno" value="<%=i2%>">
    </td>
    <%String first=request.getParameter("textfirst");
    String middle=request.getParameter("textmiddle");
    String design=request.getParameter("textdesig");
    String dept=request.getParameter("textdept");
    String Result="";
    Result=mb1.Updating(first,middle,design,dept);
    if (Result.trim().toLowerCase().equals("done")){
    out.println("Updated");
    //response.sendRedirect("content.jsp");
    }else{
    out.print(Result);
    }%>
    I am getting null value error when I click on update button for update.jsp.I know it's a looooong one.Sorry for taking u r time.Plz help. I am just submitting the abstract.

    "private static double area (int radius, final double pi)"
    final double pi? as the method parameter? ROFLHAHAHAHAHAHAHAHAHAHAHA
    That made my day.
    As for your question, make range_1 a global variable, in other words, declare it outside your main method
    Something like
    public class gary{
    int range_1;
    public static void main (String afgfg[]){
    range_1=//something;
    private static double area (int radius)
    radius = range_1
    return radius * radius * 3.14

  • How fix that Fireox url box ends in red X and prohibits access by hyperlink to other pages

    Firefox frequently freezes and hyperlinks will not function. Why? How fix?

    Start Firefox in [[Safe Mode]] to check if one of the add-ons is causing the problem (switch to the DEFAULT theme: Tools > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    See:
    * [[Troubleshooting extensions and themes]]
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")

  • Problem with variable in last page only context

    Hi,
    I am using a variable to sum the amount. And i need to print that variable in the footer of last page. I am using last page only context command(<?start@last-page-first:body?><?end body?><?call:footer_template?>) for printing the footer table in last page.
    Can i access the variable in last page only context. Its giving error for me. how can i access that variable.
    Thanks in advance.

    Yunus,
    I did what you said. I removed the variable from characteristic restrictions, saved the query and executed the query, appeared three variables Plant, Calender month and material. executed and saved the work book. disconeted from Bex analyzer, in RSRT Generated Report and logged into Bex analyzer ran the work book for selection Plant, calender month and material and went into change query definition and added the variable for customer which was removed earlier and and ran the query for selections Plant, Calender monmth, Material and customer. saved the work book. disconnected from Bex analyzer and closed all excel sheets and work books. In RSRT Generated Report and again connected to Bex analyzer and ran the work book, now appeared only three variables again missed variable customer.
    Yunus does any missed n the procedure what i did.
    It is helped what Chris was answered.
    Many Many Thaks for your time and replies.
    Thaks in advance
    Narendra

  • How to access variables from other class

        public boolean inIn(Person p)
            if  (name == p.name && natInsceNo == p.natInsceNo && dateOfBirth == p.dateOfBirth)
                 return true;
            else
                 return false;
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phello,
    here am trying to compare the existing object with another object.
    could you please tell me how to access the variables of other class because i meet this error?
    name cannot be resolved!
    thank you!

    public class Person
        protected String name; 
        protected char gender;      //protected attributes are visible in the subclass
        protected int dateOfBirth;
        protected String address;
        protected String natInsceNo;
        protected String phoneNo;
        protected static int counter;//class variable
    //Constractor Starts, (returns a new object, may set an object's initial state)
    public Person(String nme,String addr, char sex, int howOld, String ins,String phone)
        dateOfBirth = howOld;
        gender = sex;
        name = nme;
        address = addr;
        natInsceNo = ins;
        phoneNo = phone;
        counter++;
    public class Store
        //Declaration of variables
        private Person[] list;
        private int count;
        private int maxSize;
    //constructor starts
        public Store(int max)
             list = new Person[max];//size array with parameters
             maxSize = max;
             count = 0;
        }//end of store
    //constructor ends
    //accessor starts  
        public boolean inIn(Person p)
           return (name == p.name && address == p.address && natInsceNo == p.natInsceNo);
        }//returns true if Person with same name/natInsceNo/dateOfBirth as phope it helps now!

  • Application item value disapeared in other pages

    Hi
    I have created an application level item called F111_USER_AUTHENTICATION and this item is populated in the calculation section of the login page 101.
    The calculation is performed under rendering with before header and F111_USER_AUTHENTICATION is populated correctely according to some other condition in the page. I found item is populated correctly in login page when the page is loaded from a plain html page.
    But when i try to access this variable from common page 0 , value in this item is null.
    Why is the item get nullify. What is the best place to initiailzed the application level items in login page. (As apage process, or computation or else)
    Thanks
    Manjith

    Manjith - Your description is unclear on several points. Please put an example on apex.oracle.com and we can help you fix it straight away.
    Scott

  • Access custom variable value in web.xml context-param?

    My requirement or need is to access a variable value either in a class in my Model project or a backing bean in my View project. For example, one variable I need to access is an application server I am integrating with - 'testserver' or 'productionserver' - I want to be able to configure this within an external file so that I do not have to re-compile my application to change the variable.
    I was thinking about placing this variable in the web.xml <context-param> section as:
    <context-param>
    <param-name>servername</param-name>
    <param-value>testserver</param-value>
    </context-param>
    I need to access this value within a class (not a servlet) on an Application Module service method, though if needed, I could access it from a backing bean and pass it to the service method (less desirable.) Is this a good approach and how do access this variable from within a Java class including any imports I need to do (code example)?
    Thanks and Happy New Year!
    Hopefully most everyone is out spending time with friends and family versus stuck trying to complete a project like me...

    I found an example from SRDemo that provides what I was looking for:
    String serverhostaddress =
    FacesContext.getCurrentInstance().getExternalContext().getInitParameter("param-name-var-in-webxml");

  • How can I access JSP variables from a JavaScript function in a JSP page?

    Respected sir
    How can I access JSP variables from a JavaScript function in a JSP page?
    Thanx

    You may be get some help from the code below.
    <%
        String str="str";
    %>
    <script>
        function accessVar(){
           var varStr='<%=str%>';
           alert(varStr);// here will diplay 'str'
    </script>

  • Accessing user-defined context variables when chaining Proxies

    We have a Proxy Service, A, which routes to a ProxyService B, which does some routing and XML transformation.
    When an error is raised, the error text is assigned to a variable and the Error Handler for Proxy Servce B assigns soap fault XML to the body using this variable then does a Reply with Failure.
    However, Proxy Service A returns a generic BEA fault as below:
         <con:fault      xmlns:con="http://www.bea.com/wli/sb/context">
         <con:errorCode>BEA-380000</con:errorCode>
         <con:location>
         <con:node>ESB-DefaultRoute</con:node>
         <con:path>response-pipeline</con:path>
         </con:location>
         </con:fault>
    We don't appear to be able to access the context variable which we defined in Proxy Service B when we are in the Error Handler of Proxy Service A. How are we able to return a soap fault from Proxy Service A with all of the details set in B.
    Thanks in advance

    Hi,
    Yes we;re using Raise Error. I don't think my post was as clear as it could have been :-)
    In Proxy B when an error is found, then the text we want to appear in the soap fault's faultstring is assigned to a varaible, errorDetail and then Raise Error is invoked.
    We're able to access errorDetail iin the error handlers of Proxy B but not in Proxy A and it's this which is causing us the issue.
    Thanks

  • Firefox 23.0.1 crashes every time I try to access any Mozilla help page or forum, and sometimes on other pages Win 7 pro 64 bit

    Running Windows 7 Pro 64 bit and Firefox has crashed at least a couple dozen times today and nearly as many yesterday. I've tried all of the suggested "fixes", to no avail. I just tried the Windows compatibility tool mentioned in one of the forum post and that didn't resolve the issue either. I'd love to add the links to my crash reports, but can not get to this page on the computer in question - any time I try to load any Firefox or Mozilla help page, forum, etc. in that computer, Firefox crashes (even when running Firefox in Safe Mode). Firefox also crashes on miscellaneous other pages now and then. Thanks in advance for any help anyone can provide!
    In case it's helpful, below are the crash ID's for the four most recent crashes:
    Crash ID: bp-cb4e51b6-4459-4f60-bc77-39f6f2130820
    Crash ID: bp-cb4e51b6-4459-4f60-bc77-39f6f2130820
    Crash ID: bp-3ae6e6da-e687-4755-8306-178b92130820
    Crash ID: bp-275d980a-043a-48cc-9399-bcb532130820
    I'm not sure how to get the
    troubleshooting info from the computer in question into this form. I have saved the page to a file on my network, but when I try to paste the contents in the box below, most of the info is missing.

    The CrashIDs are what is needed. Do not attempt to attach or paste the reports.
    #Run Firefox in safe mode does that prevent crashes ?<br/>[[Troubleshoot Firefox issues using Safe Mode]]
    #Disable all plugins
    #Repeat and this time try in Windows safe mode. use the F8 key <br /> http://windows.microsoft.com/en-us/windows/start-computer-safe-mode#start-computer-safe-mode=windows-7
    So you are saying it works ok as long as you avoid certain pages such as this Forum. That makes me wonder if it could be malware that is blocking access to assistance.Run malwarescans with multipe and up-to-date tools.
    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/faq/?qid=208283363 TDSSKiller - AntiRootkit Utility]
    * [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
    * [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

  • HT3562 I have gone to accessibility and I turned the voice over on. It showed me the indication of zoom and I press ok but now I am not able to scroll to any other page even I am not able to go the the settings. PLEASE HELP ME OUT

    Hi
    I want to get rid of this setting of accesseibility that is not letting me do anything on my phone. I am not able to scroll to the other pages. Please help me any one who usses this and know how to solve this out

    try scrolling  and tap, with 3 fingers

  • I cannot access facebook on my MacBook Pro.  I am able to access every other website.  When trying to access facebook it says that page cannot be displayed as safari cannot establish a connection.

    I cannot access facebook on my MacBook Pro.  I am able to access every other website.  When trying to access facebook it says that page cannot be displayed as safari cannot establish a connection.  I was able to access it just fine few weeks ago....
    Please help!

    Hi Justysiag,
    If you are having issues opening a particular web site in Safari on your MacBook Pro, you may want to follow the steps in this article to see if you can resolve the issue -
    Safari 7 (Mavericks): If Safari can’t open a website
    http://support.apple.com/kb/PH17169
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • Accessing class level variable in other class.

    Hi All,
    I have one variable declared at class level i.e. global variable (non-static). In one method I am setting one value in this variable.Now I want to access this variable with this new set value in other class.
    Can anybody tell me how to do this?
    Thanks in advance.
    Neha

    Neha_20 wrote:
    Thanks for your reply. But its business req. to have byte[] as return type.
    Pls suggest me other approches as well.Comments embedded.
    Neha_20 wrote:
    *Decode.java*
    class Decode
    byte[] decodeMessage(byte []datatoReceive)
    for(int i=0,j=6; i<dataLen && j<j+responseData.length;i++,j++)
    responseData[i] = datatoReceive[j];
    System.out.println("Response Data [ "+i +" ]"+responseData);
    Syntax syntaxObj1 = new Syntax(); // this creates a Syntax instance     
    syntaxObj1.returnData(responseData); // this populates it
    return responseData; // now it goes out of scope and disappears
    Neha_20 wrote:
    *User.java*
    class User
    public static void main(String args[])
    // this creates a new unpopulated Syntax instance
    Syntax syntaxObj = new Syntax();
    for(int i =0;i<syntaxObj.dataRet.length;i++)
    System.out.println("dataRet [ "+i+ " ]"+syntaxObj.dataRet);

  • How to populate a filter field in one page with the value from other page

    Take the classic report with form application.
    on page 1 (report) I have a filter (dbname) for the records that will appear in the report. Say that, I enter "ap02" in the filter and all records where dbname starts with "ap02" will display. It works ok.
    Then I click on "create" button and page 2 appears. I enter all fields except the dbname. This field is generated, at "pre-insert trigger on the table".
    What I want is when I press the button "create" on page 2 to pass the value of the generated dbname field into the filter in page 1 so when that page refreshes I will have only one record on the report page (1). I understand that the dbname at the page 2 level still empty because it is generated by the trigger. How do I have access to that info to populate the filter.
    Thanks for your assistance

    Joe - Work backwards from the value generated during the execution of the trigger. You have the value there so you could save it into a package variable right then (create a package with a variable and assign the value to the variable). Then create a process on the page (after the DML process) to assign the value of your package variable to a page item. Then in the branch back to page 1, pass the item. (Or without messing with the branch, the process could simply assign the package variable directly the the page 1 item -- :P1_ITEM := my_package.my_var; ).
    An alternative would be to use the "returning into" feature of DML to capture the PK of the created record into an item. Then the next page process could use the PK to fetch the new row and get the dbname value for passing to page 1.
    Another option would be to update session state directly in the trigger.
    Scott

Maybe you are looking for