Finding a component inside jsf fragment using javascript in adf

Hello all,
I am using jdeveloper 11.1.1.5.
I want to find a component inside my jsf frgament using javascript.
Like inside jspx page I was able to find the component using
AdfPage.PAGE.findComponentByAbsoluteId("ID");
Now my requirement is I have a jsf fragment and I want to find component inside jsf frgament using javascript.
How can I find the component?
Please suggest
Thanks
Edited by: Navin K on Dec 21, 2011 4:24 PM

Hi all..
I am using Jdeveloper 11.1.2.1.0
The code i used is given below. When i run this i always getting the message (ie region not found) in the else case of java script.
How can i solve this. How can i take the region r1 in the javascript..
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<f:view xmlns:f="http://java.sun.com/jsf/core" xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
<af:document title="Index.jsf" id="d1">
<af:messages id="m1"/>
<af:form id="f1">
<af:pageTemplate viewId="/AssetTrackingTemplate.jsf" id="pt1">
<f:facet name="top"/>
<f:facet name="first">
<af:panelAccordion id="pa1">
<af:showDetailItem text="Master Details" id="sdi1">
<af:spacer width="10" height="10" id="s3"/>
<af:commandLink text="Home" id="cl8" inlineStyle="font-size:small; font-weight:bold;">
<af:setActionListener from="/WEB-INF/task-flow-Home.xml#task-flow-Home"
to="#{pageFlowScope.dynRegionBean.taskFlowId}"/>
</af:commandLink>
<af:spacer width="10" height="10" id="s1"/>
<af:tree value="#{bindings.GenTopMenu1.treeModel}" var="node"
selectionListener="#{bindings.GenTopMenu1.treeModel.makeCurrent}"
rowSelection="single" id="t1">
<f:facet name="nodeStamp">
<af:group id="g1">
<af:outputText value="#{node.Description}" id="ot2"
rendered="#{node.MenuType==1}"/>
<af:commandLink text="#{node.Description}" id="cl1"
rendered="#{node.MenuType==2}" partialSubmit="true"
immediate="false"
actionListener="#{pageFlowScope.dynRegionBean.launchTaskFlow}">
<f:attribute name="Definition" value="#{node.Definition}"/>
</af:commandLink>
</af:group>
</f:facet>
</af:tree>
</af:showDetailItem>
</af:panelAccordion>
</f:facet>
<f:facet name="middle">
<af:region value="#{bindings.dynamicRegion1.regionModel}" id="r1"/>
</f:facet>
<f:facet name="end"/>
<f:facet name="copyright">
<af:outputText value="All Rights Reserved By Innovation ITC" id="ot1"
inlineStyle="text-align:center; color:inherit;"/>
</f:facet>
</af:pageTemplate>
</af:form>
<f:facet name="metaContainer">
<af:resource type="javascript">
function customHandler(event) {
var region=AdfPage.PAGE.findComponentByAbsoluteId("r1");
if(region!=null)
alert("Region Found");
var exportCmd = region.findComponent("cb1");
var actionEvent = new AdfActionEvent(exportCmd);
actionEvent.forceFullSubmit();
actionEvent.noResponseExpected();
actionEvent.queue();
else {
alert("Region Not Found")
</af:resource>
</f:facet>
</af:document>
</f:view>
Thanks,
gtg.
Edited by: gtg on 08-Feb-2012 00:14

Similar Messages

  • PartialTrigger point to Component within JSF Fragment

    i like know if it is possible to have component within mainPage.jspx with partialTrigger pointing to component within a JSF Fragment which is included in mainPage.jspx.
    A use case for it could be, for example, i have a tabbed panel with 2 tabs, each tab contains a JSF Fargment per jsp:include, in the first tab there is a table with search result and the second tab should show the detaisl of the selected table item by double-click or context menu of the item.
    Thanks in advanced.

    Hi,
    since you don't mention af:region, I assume you don't use it. In this case, have a look here: http://thepeninsulasedge.com/frank_nimphius/2008/02/14/adf-faces-how-to-issue-a-ppr-event-from-a-fsubview-and-how-to-ppr-of-subviews/
    Frank

  • Problem with access JSF applet using javascript

    Can someone help me!
    I'm using a applet in jsf page, and i'm trying to access this applet using a javascript.
    Here is the applet code
    <jsp:plugin code="DoAction.class" codebase="." height="400" hspace="10" jreversion="1.5" type="applet" vspace="50" width="100" name="myApp"/>
    Here is the javascript
    function printReturn()
    var a = document.myApp.returnString();
    alert(a);
    "returnString" is the method in applet which simply return a string
    But it doesn't work, it works well when i'm using this applet in JSF
    <applet code="DoAction.class" width="100" height="50" name="myApp" ></applet>
    Unfortunately it's depricated!
    Please tell me what is the solution....

    Thank You for replying.
    I'm trying to call applet method using JavaScript.
    It works when i'm using below apllet tag.
    <applet code="DoAction.class" width="100" height="50" name="myApp" ></applet>
    But it's deprecated
    It doesn't work for below applet tag
    <jsp:plugin code="DoAction.class" codebase="." height="400" hspace="10" jreversion="1.5" type="applet" vspace="50" width="100" name="myApp"/>
    This is my javascript
    <script type="text/javascript">
    function setSearch()
    var a = document.myApp.returnString();
    alert(a);
    </script>

  • Find the startpage of current web using javascript?

    I want to hide a "div" from all startpages/welcomepages. But I cant just compare "start.aspx" and my url parameter cause sometimes the page "start.aspx" isn't there in the url. Is there a way to know if I'm on a "startpage"
    or not using javascript?

    SPWeb has RootFolder which internally has WelcomePage property. You can use that to get this information
    var clientContext = new SP.ClientContext.get_current();
    var spWeb = clientContext.get_web();
    var rootFolder = spWeb.get_rootFolder();
    clientContext.load(rootFolder, 'WelcomePage');
    clientContext.executeQueryAsync(Function.createDelegate(this, onQuerySucceeded), Function.createDelegate(this, onQueryFailed));
    function onQuerySucceeded() {
    alert(rootFolder.get_welcomePage());
    function onQueryFailed(sender, args) {
    alert('error');
    In case of publishing web
    var web = context.get_web();
    var pubWeb = SP.Publishing.PublishingWeb.getPublishingWeb(context, web);
    context.load(pubWeb, 'DefaultPage');

  • How to Redirect to another page Using JavaScript in ADF Faces?

    Hi Guys,
    I have a UI user case that has a af:menu which contains mutiple af:goMenuItem. When user click on the menu, the menu slides down and shows up the af:goMenuItem. As we know, you could define the page destinations in af:goMenuItem to go to another page when user clicked, but af:menu itself cannot be redirected to another page. Well, the user case wants the menu itself could be redirected if user click on it.
    So I am thinking using JavaScript to do this: when the af:menu gets clicked, redirect to another page. BUT, I looked over the ADF Faces Javascript API and was not able to find that piece of code to do this. Any help???
    Another work around for the user case scenario is to use HTML marks + CSS/JavaScript instead of af:menu and af:goMenuItem but this changes the scope of technology although it's not hard to do
    Any other idea to accomplish the user case other than what I could think of ?
    Thanks Guys!
    Jay

    Hi,
    1 - you can have a hidden command item to do the navigation based on a control flow case. In this case, you access the command component from JavaScript create a new ActionEvent and queue it
    2 - JavaScript can use an af:serverListener to call into a server side managed bean method to perform the navigation
    there is no JavaScript API for navigation in ADF Faces because navigation in JavaServer Faces is an event driven framework and we don't support developers fighting the framework.
    Frank

  • How to find a component inside region at the bean level

    Hi,
    Am using JDEV 11.1.2.0.0 . As per requirement developing a sample to use keyboard shortcut .. Registered the keys combination in the js and added the respective client and server listeners. My requirement goes as follows..
    1. Have a .jspx page called -> HotKeys.jspx.
    2. In the .jspx page have a region called DepartmentTF -> Department.jsff that in turn holds the navigation buttons.
    First -> Ctrl + F
    Next -> Ctrl + N
    3.Having running the page , when i give Ctrl + N , it should identify the Next button and trigger the respective code..
    But the issue is how do i found the Next button component at bean level...
    Thanks and Regards,
    Vinitha G

    Hi,
    if the JSFF is always shown in the region, then you could access the button with the knowledge of the path it sits in
    1. find the regions
    RichRegion _region = uiViewRoot.findComponent("regionId");
    2.
    _region.findComponent("idOfNextButton");
    If you need this to be more dynamic, have a read here:
    http://www.oracle.com/technetwork/developer-tools/adf/downloads/58-optimizedadffacescomponentsearch-175858.pdf
    Frank

  • Can you find a string inside of apdf using cfpdf in Coldfusion?

    Is it possilbe to determine if a String, for example "Not Possible",  exists in a PDF using CFPDF or another function inside of Coldfusion?  If so, any suggestions on how to do this would be appreciated.
    Thanks!

    Yes, it is possible. In the following example, the 2 files and the PDF ('myDoc.pdf') are in the same directory.
    textFromPDF.cfm
    <!--- Convert from PDF to text and search text --->
    <cfset currentDir = getDirectoryFromPath(expandpath('*.*'))>
    <cfset ddxfile = "#currentDir#myDDX.ddx">
    <cfset inputStruct=StructNew()>
    <cfset inputStruct.Doc1= "#currentDir#myDoc.pdf">
    <cfset outputStruct=StructNew()><!--- Coldfusion automatically saves the text as XML file --->
    <cfset outputStruct.Out1="#currentDir#my_PDF_doc_as_text.xml">
    <cfpdf action="processddx" ddxfile="#ddxfile#" inputfiles="#inputStruct#" outputfiles="#outputStruct#" name="myDDXVar">
    <cfif myDDXVar.out1 is "successful"><!--- read the text --->
        <cffile action="read" file="#currentDir#my_PDF_doc_as_text.xml" variable="my_PDF_doc_as_text">
    </cfif>
    Position of search text "Not Possible": <cfoutput>#findNoCase("Not Possible",my_PDF_doc_as_text)#</cfoutput>
    myDDX.ddx
    <?xml version="1.0" encoding="UTF-8"?>
    <DDX xmlns="http://ns.adobe.com/DDX/1.0/"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://ns.adobe.com/DDX/1.0/ coldfusion_ddx.xsd">
       <DocumentText result="Out1">
          <PDF source="Doc1"/>
       </DocumentText>
    </DDX>

  • Partial submit in a jsf fragment is not working

    Hi,
    i have a jsf page that is hosting a jsf fragment (using workflow), inside the jsf fragment i have a button that has partial submit = true, and an output text that has partial triggers pointing to the button.
    the button on the fragment page has a "set action listener" that update a variable in a managed bean.
    the output text on the fragment page is displaying the content of that variable (which the button is updating).
    the problem is that partial submit is not working and whenever the button is clicked and the value of the variable inside the managed bean is changed , it is not reflected in the output text.
    note that if you try to use this example in a normal JSF page it will work, so does anybody knows what is wrong.
    i'm using Jdeveloper 11.1.1.2
    ************************** source code of the jsf fragment page *********************************
    <?xml version='1.0' encoding='windows-1252'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
    xmlns:f="http://java.sun.com/jsf/core">
    <af:commandButton text="commandButton 1" id="cb1" partialSubmit="true">
    <af:setActionListener from="#{not DepartmentInquiryBean.getterCriteriaPanelDisplayInd}"
    to="#{DepartmentInquiryBean.setterCriteriaPanelDisplayInd}"/>
    </af:commandButton>
    <af:outputText value="#{DepartmentInquiryBean.getterCriteriaPanelDisplayInd}" id="ot1"
    partialTriggers="cb1"/>
    </jsp:root>
    ************************** source code of the managed bean ************************************
    package Merch.Model;
    public class DepartmentInquiry {
    private boolean CriteriaPanelDisplayInd = true;
    public DepartmentInquiry() {
    public void setSetterCriteriaPanelDisplayInd(boolean p_CriteriaPanelDisplayInd) { 
    CriteriaPanelDisplayInd = p_CriteriaPanelDisplayInd;
    public boolean getGetterCriteriaPanelDisplayInd() {
    return CriteriaPanelDisplayInd;
    ********************************************************************************************

    Yes, try appending the region's id to the component inside that region.
    i.e.
    <af:outputText value="#{DepartmentInquiryBean.getterCriteriaPanelDisplayInd}" id="ot1"
    partialTriggers="r1:cb1"/>^ assuming 'r1' is your region's id.
    If your fragment is not inside a region...maybe try doing so.
    Also, see here:
    Referencing a component on a page fragment inside an <af:region>.
    Best of luck.
    Matthew.
    Edited by: Matthew Carrigy on 27/11/2009 10:42

  • Possible to save files in My Documents using JavaScript?

    I have a customer who wants his users (service technicians) to be prompted to save a PDF form they fill out, print, and sign for their customers. It's easy to set the File>Save As action for the form button, but my customer wants to know if it's possible to always have the form saved to My Documents.
    I've searched the form and haven't been able to find any discussion on this. I can't imagine how to do it, since My Documents is inside the user profile... but was wondering what people who actually know what they're talking about (as opposed to me, that is) might have to say.
    If it is possible to do what my customer wants, can you point me to any existing code or reference sources?
    Cheers!
    ---Fox

    But I have two problems with this...
    The first is that I ran several Google site-searches and Adobe searches, but did not find any document*** named Acrobat JavaScript API Reference, even though it is also directly referenced in the Acrobat 9 help (listed there as JavaScript™ for Acrobat® API Reference, but I've searched using broader terms such as API reference and other combinations, and it simply did not come up).
    I did find the companion "Developing Acrobat® Applications Using JavaScript". But it's overwhelming, and I don't know what chapter(s) contain the information I need to throw together a proper working script for what I need.
    That's the other problem.
    I do not know JavaScript. I know how to include it but not how to write it. Everywhere I look, the blanket response to newbie JavaScript questions is to dump the wad of documentation in the asker's lap, expecting them to sit down and read it "cover to cover."  I now have a long-overdue project and I need help, fast. I don't have time to learn JavaScript from scratch! -- If I did, I wouldn't be asking these questions! I'd be figuring it out myself.
    This is becoming very frustrating. Won't somebody please help me out, or tell me exactly what pieces of code I need to put in and where I need to put it?  I can at least go look up the syntax, as long as I know what to look for.
    EDIT:  *** Now that I've written that, I ran the Adobe search tool again and found the PDF version, which is what I was looking for. The saveAs samples make no sense to me, and I keep trying to dig back through the documentation to figure out what the heck it's talking about. It's a quagmire. The documentation is barely understandable; it's very poorly worded, and every sentence is thick with unfamiliar concepts for a n00b -- and I'm a tech writer!
    Message was edited by: FoxCole

  • Problem with using javascript in interactive adobe form

    Hi All,
        I have a problem when accessing text field value which is present inside a subform using javascript.
    I tried giving data.page4.sub-5.<fieldname>.rawvalue but its not working. Please provide a solution.
    Thank you in Advance.

    Since this question is related to JavaScript running within the Form and not the connection between the form and Web Dynpro - it really belongs in the Interactive Forms by Adobe Forum.

  • Use javascript inside page fragment

    Im trying to use javascript code inside a page fragment with the tag
    af:resource
    But the second time the page reloads i got this error: "ReferenceError: funciona is not defined"
    <af:resource type="javascript">
          function funciona() {
              alert(123);
    </af:resource>
    Im using JDeveloper 12c

    The resource is added to the af:document component to be included when the document is rendered. The resource is only processed on the initial creation of the document.
    are you sure, af:resourse tag presence under af:document.?

  • Can't submit JSF using Javascript

    I apologize if this is an obvious newbie question.
    I have a simple JSF page with a component users can click on to select a number. Using Javascript, I populate a textbox with the number they select, then attempt to submit the form, also using Javascript. But this doesn't work.
    The form submits and returns as though the user had submitted without a value in the textbox, and then their number appears in the textbox (it should be empty at this point).
    The form works fine if I use Javascript only to set the value in the textbox and require the user to manually press the Submit button.
    TIA for any help!

    Sorry, this is in the wrong place (and I can't find a way to delete it). Please ignore.

  • Problem using javascript to submit jsf form, values not submitted

    Greetings!
    I have a t:selectOneMenu where I want the page to be submitted when they change the selected value. At this point, I am able to get the form to submit and reload the page, which is all fine. The problem is that none of the values from the page are not set in the backing bean. I have break points on the setter methods that are not being hit.
    I have tried a number of things from searching multiple forums, but here are snippets from my latest version...
    <h:form>
    <t:commandLink id="hiddenLink" forceId="true" value="test link"
    action="#{pc_PageX.doBtnHiddenLinkAction}"></t:commandLink>
    <t:selectOneMenu id="pageList_top" forceId="true" value="#{pc_PageX.ValueX}"
         onchange="jspellSync(); submitPageX();">
         <f:selectItems value="#{pc_PageX.ListX}" />
    </t:selectOneMenu>
    </h:form>
    function submitPageX(){
         var hiddenLink = document.getElementById("hiddenLink");
         hiddenLink.click();
    }Note that the <t:commandLink> is not hidden, though it will be in the final version if I can get this to work.
    If I click the commandLink myself, the page is submitted with all the page values as expected. If I change the list value, thus using javascript to fire the commandLink's click event, the page is submitted with NO values.
    Can anyone come up with an explanation for this behavior? Or better yet, a solution?
    A couple other things I've tried...
    - Not using a commandLink and using jsf's submit function -> onchange="jspellSync(); submit();"
    - Clicking the link using other ways -> hiddenLink.fireEvent('onclick');
    If all else fails, I'll just add a button that they have to click to submit the form.

    snotmare wrote:
    BalusC wrote:
    I recall this problem in one of the ancient JSF versions. Which JSF version do you use? Do you have any room to upgrade to latest? We're using an IBM implementation of JSF, which is at version 7.0. The IBM implementation appears to be built on the JSF base 1.1.That's not an IBM JSF implementation, they do not have any one, they just have some component libraries which runs on top of some JSF implementation. RAD/WSAD ships by default with Sun JSF RI. Try upgrading to at least 1.1_02 which you can download from the aforementioned link. There's a gap of 2 years (and inherently a lot of bugfixes) compared to 1.1. If the application server used supports Servlet 2.5, you could even upgrade to the latest 1.2.
    We've had other issues with the IBM implementation, which could be the cause in this case too. We've been talking about switching to MyFaces, but there is one feature of the IBM version that we like. It's basically a script collector (hx:scriptCollector) that allows us to do pre-processing on the page.As said before, IBM does not have a JSF implementation. So replacing RI by MyFaces wouldn't make any difference.

  • Pre-validation using JavaScript cannot work in JSF?

    Sometimes we need to do pre-validation using JavaScript in some senarios that data need be entered and validated at client site before it reaches to Web Application Server. Remind that JSF is a server validation. Creator seems not to allow Developers to do pre-validation using JavaScript for any editable input fields in form. I will illustrate an example and hope anyone can help me to solve it out.
    Assume that if we write the a new web page that allows User enters Name and Phone. The pre-validation function called test() is written in JavaScript for validating field Phone. For simplicity, the below HTML/JavaScript without nested in table is a simple one for HTML form.
    <html>
    <body>
    <script language="JavaScript">
    function test(){
         if (form1.phone.value == "")
              alert("Please enter phone number in digits.");
              return false;
    </script>
    <form name=form1>
    <input id="phone" type="text" size=20><Br>
    <input id="name" type="text" size=20><Br>
    <input type="submit" id="submit" onclick="test()" value="Submit">
    </form>
    </body>
    </html>
    Now, we consider using Java Studio Creator to generate the same form as describing above. The script is shown below:
    <?xml version="1.0"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <html>
    <head>
    <title>testForm Title</title>
    </head>
    <body rave-layout="grid">
    <h:form binding="#{testForm.form1}" id="form1">
    <h:inputText binding="#{testForm.textField1}" id="phone" style="position: absolute; left: 192px; top: 96px; width: 168px; height: 23px"/>
    <h:inputText binding="#{testForm.textField2}" id="name" style="position: absolute; left: 192px; top: 144px; width: 168px; height: 23px"/>
    <h:commandButton binding="#{testForm.button1}" id="submit" style="position: absolute; left: 192px; top: 216px" value="Submit"/>
    </h:form>
    </body>
    </html>
    </f:view>
    </jsp:root>
    After running Script that Creator created, the HTML is generated and reduced (for simplicity) as follows:
    <f:view>
    <html>
    <body rave-layout="grid">
    <form action="/rave/rave" id="form1" method="post">
    <input id="form1:Phone" type="text"></input>
    <input id="form1:name" type="text"></input>
    <input id="form1:button1" value="Submit" onClick="test()"></input>
    </body>
    </html>
    </f:view>
    Take a look carefully at <input> elements. We see the syntax for naming for each "input" element that there is a semi colon added between form1 and phone or form1 and name. This syntax is generated from built-in JSF components. Hence, I rewrite the test() JavaScript function to match with the naming that Creator generated as follows:
    <script language="JavaScript">
    function test(){
         if (form1.form1:Phone.value == "")
              alert("Please enter phone number in digits.");
              return false;
    </script>
    Clearly, this JavaScript cannot be worked because of a semi column that Creator has named it.
    I have tried to work arround for this but cannot find a solution except changing the name such as: from <input id="form1:phone" ...> to <input id="form1_phone" ..>. But I could not change or modify the scripts because it is generated from JSF components when running it under browser.
    I guess to solve this problem, the naming for elements in form should be reconsidered in the next release of Java Studio Creator.

    Hi Marie,
    I currently sucess in client pre-validation using JSF. I found a way to do it.
    Please take a look of how javascript has been added in the following scripts:
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <html lang="en-US" xml:lang="en-US">
    <head>
    <meta content="no-cache" http-equiv="Cache-Control"/>
    <meta content="no-cache" http-equiv="Pragma"/>
    <title>login Title</title>
    </head>
    <body style="-rave-layout: grid">
    <h:form binding="#{login.form1}" id="form1">
    <h:outputLabel binding="#{login.componentLabel1}" for="componentLabel1" id="componentLabel1" style="position: absolute; left: 216px; top: 72px">
    <h:outputText binding="#{login.componentLabel1Text}" id="componentLabel1Text" value="Application System Name"/>
    </h:outputLabel>
    <h:panelGrid binding="#{login.gridPanel1}" columns="3" id="gridPanel1" style="position: absolute; left: 72px; top: 168px; width: 504px; height: 100px">
    <h:outputLabel binding="#{login.componentLabel2}" for="componentLabel2" id="componentLabel2">
    <h:outputText binding="#{login.componentLabel2Text}" id="componentLabel2Text" value="User Name: "/>
    </h:outputLabel>
    <h:inputText binding="#{login.textField1}" id="textField1" onclick="" style="width: 149px; height: 22px"/>
    <h:outputText binding="#{login.outputText1}" id="outputText1"/>
    <h:outputLabel binding="#{login.componentLabel3}" for="componentLabel3" id="componentLabel3">
    <h:outputText binding="#{login.componentLabel3Text}" id="componentLabel3Text" value="Password: "/>
    </h:outputLabel>
    <h:inputSecret binding="#{login.textField2}" id="textField2" style="width: 147px; height: 22px"/>
    <h:outputText binding="#{login.outputText2}" id="outputText2"/>
    <h:outputLabel binding="#{login.componentLabel4}" for="componentLabel4" id="componentLabel4">
    <h:outputText binding="#{login.componentLabel4Text}" id="componentLabel4Text"/>
    </h:outputLabel>
    <h:commandButton action="#{login.ok_action}" binding="#{login.button1}" id="button1" onclick="return checkUserIdentity(this.form)"
    style="width: 90px; height: 25px" value="OK"/>
    <h:outputLabel binding="#{login.componentLabel5}" for="componentLabel5" id="componentLabel5">
    <h:outputText binding="#{login.componentLabel5Text}" id="componentLabel5Text"/>
    </h:outputLabel>
    </h:panelGrid>
    </h:form>
    </body>
    <script type="text/javascript">
    function checkUserIdentity(form){
    var userName = form["form1:textField1"].value;
    var userPassword = form["form1:textField2"].value;
    if (userName == "") {
    alert("Please enter User Name.");
    form["form1:textField1"].focus();
    return false;
    if (userPassword == "" ){
    alert("Please enter password.");
    form["form1:textField2"].focus();
    return false;
    form.submit();
    return true;
    </script>
    </html>
    </f:view>
    </jsp:root>
    The key for getting data value from Form based on Javascripts is var userName = form["form1:textField1"].value;
    Thanks,
    VTT_

  • Unable to update rating (rating column) on host document using JavaScript Object Model API inside sharepoint hosted apps

    Hi Everyone,
    We are developing SharePoint hosted apps for Office 365, for that we are going
    to implement document rating functionality inside Sharepoint app. The host web contain document library (“Documents”) and from apps we need to rate each document. The rating functionality working fine with CQWP in team site  using
    JavaScript Object Model API.
    But the same code is not working inside apps and giving error:-
    If we are using app context than error will be:-
    "List does not exist.
    The page you selected contains a list that does not exist.  It may have been deleted by another user."
    And for Host context than error will be:-
    "Unexpected response data from server."
    Please help on this
    Please see below code..
    'use strict';
    var web, list, listItems, hostUrl, videoId, output = "";
    var videoLibrary = "Documents";
    var context, currentContext;
    var lists, listID;
    var list, parentContext;
    var scriptbase;
    (function () {
        // This code runs when the DOM is ready and creates a context object which is 
        // needed to use the SharePoint object model
        $(document).ready(function () {
            hostUrl = decodeURIComponent(getQueryStringParameter("SPHostUrl"));
            context = SP.ClientContext.get_current();      
            SP.SOD.executeFunc('sp.js', 'SP.ClientContext', sharePointReady);
        function sharePointReady() {
            scriptbase = hostUrl + "/_layouts/15/";
            // Load the js files and continue to the successHandler
            $.getScript(scriptbase + "SP.Runtime.js", function () {
                $.getScript(scriptbase + "SP.js", function () {
                    $.getScript(scriptbase + "SP.Core.js", function () {
                        $.getScript(scriptbase + "reputation.js", function () {
                            $.getScript(scriptbase + "sp.requestexecutor.js", execCrossDomainRequest);
        //Query list from hostweb
        function execCrossDomainRequest() {       
            //Load the list from hostweb
            parentContext = new SP.AppContextSite(context, hostUrl);
            web = parentContext.get_web();
            list = web.get_lists().getByTitle(videoLibrary);
            context.load(list, 'Title', 'Id');
            var camlQuery = new SP.CamlQuery();
            camlQuery.set_viewXml('<View><Query><OrderBy><FieldRef Name="Modified" Ascending="FALSE"/></OrderBy></Query><RowLimit>1</RowLimit></View>');
            listItems = list.getItems(camlQuery);        
            context.load(listItems);
            context.executeQueryAsync(onQuerySucceeded, onQueryFailed);
        //Process the image library
        function onQuerySucceeded() {       
            var lstID = list.get_id();
            var ctx = new SP.ClientContext(hostUrl);       
            var ratingValue = 4;
            EnsureScriptFunc('reputation.js', 'Microsoft.Office.Server.ReputationModel.Reputation', function() {      
            Microsoft.Office.Server.ReputationModel.Reputation.setRating(ctx, lstID, 1, ratingValue);       
            ctx.executeQueryAsync(RatingSuccess, RatingFailure);
        function onQueryFailed(sender, args) {
            alert('Failed' + args.get_message());
        function failed(sender, args) {
            alert("failed because:" + args.get_message());
        function RatingSuccess() {
            alert('rating set');
            //displaystar();
        function RatingFailure(sender, args) {
            alert('Rating failed : : ' + args.get_message());
        //Gets the query string paramter
        function getQueryStringParameter(paramToRetrieve) {
            var params;
            params = document.URL.split("?")[1].split("&");
            for (var i = 0; i < params.length; i = i + 1) {
                var singleParam = params[i].split("=");
                if (singleParam[0] == paramToRetrieve) return singleParam[1];
    Thanks & Regards
    Sanjay 
    Thank you in advance! :-)
          

    Hi,
    According to your post, my understanding is that you want to update list column in SharePoint hosted apps using JavaScript Client Object Model.
    Based on the error message, it seems not retrieve the list object in context. I suggest you debug the code step by step using Internet Explorer Developer Tools to
    find the problem.
    Here are some demos about using JavaScript Client Object Model in SharePoint hosted app:
    http://blogs.msdn.com/b/officeapps/archive/2012/09/04/using-the-javascript-object-model-jsom-in-apps-for-sharepoint.aspx
    http://sharepoint.stackexchange.com/questions/55334/how-to-access-list-in-sharepoint-hosted-app
    http://www.dotnetcurry.com/showarticle.aspx?ID=1028
    Best regards
    Zhengyu Guo
    TechNet Community Support

Maybe you are looking for