How do Javascript refer to JSF IDs?

Hi
I have a JSF page and want to launch a java script (calendar pick date popup) from it.
The java script pass in the HTML input ID (inputText0) of the input field to populate (result from date pick).
But, I do not know the HTML input ID since JSF generate an ID (_id2:inputText0).
Here is the JSF code:
<h:form>
<script type="text/javascript">
var calDFrom = new CalendarPopup("testdiv1");
calDFrom.showNavigationDropdowns();
</script>
<h:panelGrid columns="2">
<h:panelGroup>
<h:outputLabel id="outputLabel0" value="#{msg.repInFromDate}" for="inputText0" styleClass="fieldOutputHeaderLabel"/>
</h:panelGroup>
<h:panelGroup>
<h:inputText id="inputText0" value="#{sessionActionListener.depotSales.fromDate}" required="true">
<f:validator validatorId="dateValidator"/>
</h:inputText>
<h:graphicImage onklick="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" title="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" id="anchorCalDFrom" alt="jsf-sun" url="/images/calendar.gif" />
</h:panelGroup>
</h:panelGrid>
</h:form>
Here is an extract of the HTML rendederd by JSF:
<tr class="detailDataTableRow">
<td class="detailDataTableColumn"><label id="_id2:outputLabel0" for="_id2:inputText0" class="fieldOutputHeaderLabel">
From Date</label></td>
<td class="detailDataTableColumn"><input id="_id2:inputText0" type="text" name="_id2:inputText0" class="fieldInputDetailText" /><img id="_id2:anchorCalDFrom" src="/OrderSystem-ViewController-context-root/images/calendar.gif" alt="jsf-sun" onklick="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" title="calDFrom.select(document.forms[0].inputText0,'anchorCalDFrom','yyyy-MM-dd'); return false;" /></td>
</tr>
How do I solve this problem?
Henkie

Assign an unique ID to the h:form and use document.getElementById() in JS. You can also make use of the 'this' reference in JS and then crawl through the parent form and/or the DOM tree.

Similar Messages

  • How to do Javascript validations in JSF

    Hi ,
    I want to know about the javascript validation in JSF. I want to know simple validations like field should not be empty.
    I have a problem with my code can any one suggest me on this. for your reference here i'm attaching my code.
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c"%>
    <f:view>
         <%@ include file="../includes/header.jsp"%>
         <h:form id="createForm">
              <script>   
             function validate() { 
                 if((document.createForm.courseId.value=='') ||(document.createForm.courseId.value==null))
                    alert("Please Enter Course Id");     
                     return false; 
                 if(document.createForm.fileName.value=='')
                    alert("Please Enter File Name");     
                     return false; 
                   retutrn true;
                         </script>
              <table width="768" height="100%" border="0" cellpadding="0"
                   cellspacing="0">
                                  <tr>
                                                      <td width="200" height="25" align="left" class="formtext">
                                                           Course Id:
                                                      </td>
                                                      <td height="25" align="left">
                                                           <h:inputText id="courseId"  value="#{bean.courseId}"  required="true"  />
                                                      </td>
                                                 </tr>
                                                 <tr>
                                                      <td width="200" height="25" align="left" class="formtext">
                                                           File Name:
                                                      </td>
                                                      <td height="25" align="left">
                                                           <h:inputText id="fileName" value="#{bean.fileName}" />
                                                      </td>
                                                 </tr>
                                            </table>
                                  <tr>
                                       <td colspan="2" align="center" class="formtext">
                                            <h:commandButton value="Create"
                                                 action="#{control.getSelectedItems}"
                                                 onclick=" return validate();" />
                                       </td>
                                  </tr>
                             </table>
                        </td>
                        <td width="12" valign="top" background="images/tile_left_right.jpg">
                             <img src="images/tile_left_right.jpg" width="6" height="1" />
                        </td>
                   </tr>
              </table>
         </h:form>
         <%@ include file="../includes/footer.jsp"%>
    </f:view>

    Have you checked the element ID's? Maybe you have overlooked the woodstocked ID's. Look in the generated HTML source and base your Javascript on this.

  • What does the scriptcollector do and how does it related to jsf lifecycle?

    hi,
    i want to know what does the scriptcollector do and how does it related to jsf lifecycle? and also in the scriptcollector if i call this,
    preRender=#{myBean.onPageLoadBegin}
    postRender=#{myBean.onPageLoadEnd}
    how my page will react?

    The hx:scriptCollector is part of the IBM Faces Client Framework and has nothing to do with Sun JSF RI.
    Lot of the hx components require specific Javascript and those hx components should be placed inside a single hx:scriptCollector which on its turn checks the nested hx components and renders the desired Javascript for it at the end of the tag. Check the HTML source for that Javascript.

  • How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes?

    How can I use 2 Apple IDs in Itunes? I have 2 IOS Devices. They each have there own AppleID. What is the proper way to sync both of them to Itunes? I wanted my teenager's AppleID to be different from mine so that she couldn't charge stuff to my AppleID, therefore I created me another one. Now when I go to Sync either device, it tells me that this IOS device can only be synced with one AppleID. Then I get a message to erase it, not going to do that, lol. If I logout as one ID and login as the other, will it still retain all synced information on the PC from the first IOS device? If I can just log in out of the AppleID, then I have no problem doing that as long as the synced apps, music, etc stays there for both. I am not trying to copy from one to the other, just want to make sure I have a backup for the UhOh times. If logging in and out on the same PC of multiple AppleIDs is acceptible then I need to be able to authorize the PC for both devices. Thanks for the help. I am new to the iOS world.

    "Method Three
    Create a separate iTunes library for each device. Note:It is important that you make a new iTunes Library file. Do not justmake a copy of your existing iTunes Library file. If iTunes is open,quit it.
    This one may work. I searched and searched on the website for something like this, I guess I just didn't search correctly, lol. I will give this a try later. My daughter is not be back for a few weekends, therefore I will have to try the Method 3 when she comes back for the weekend again. "
    I forgot to mention that she has a PC at her house that she also syncs to. Would this cause a problem. I am already getting that pop up saying that the iPod is synced to another library (even though she is signed in with her Apple ID to iTunes) and gives the pop up to Cancel, Erase & Sync, or Transfer Purchases. My question arose because she clicked on "Erase & Sync" by mistake when she plugged the iPod to her PC the first time. When the iPod was purchased and setup, it was synced to my PC first. When she went home, she hooked it up to her PC and then she erased it by accident. I was able to restore all the missing stuff yesterday using my PC. However, even after doing that it still told me the next time I hooked it up last night that the iPod was currently synced with a different library. Hopefully, you can help me understand all this. She wants to sync her iPod and also backup her iPod at both places. Both PCs have been authorised. Thanks

  • TS1741 How do I have multiple apple IDs on one Apple TV 5.3

    I have looked and looked but I can't find a way to put both mine and my boyfriends apple IDs onto this Apple TV that I just bought him.  It's the 5.3 version, I went under general, settings, and then iTunes Store, and there isn't a accounts option, it's just a sign in option so how can we both use our phones as remotes?

    Well, you could save multiple Apple ID on your Apple TV, but you can't use them at the same time!
    To add and manage multiple Apple IDs on Apple TV, follow this guide:
    How to add, manage multiple Apple IDs on the same Apple TV

  • How do I add multiple apple ids to my computer iTunes

    How do I add multiple apple ids to my computer iTunes account

    You can authorize more than one account.
    iTunes Store: Authorize or deauthorize your Mac or PC

  • How do I consolidate multiple iCloud IDs?

    How do I consolidate multiple iCloud IDs?

    In order to change your Apple ID or password for your iCloud account on your iOS device, you need to delete the account from your iOS device first, then add it back using your updated details. (Settings > iCloud, scroll down and hit "Delete Account")
    Providing you are simply updating your existing details and not changing to another account, when you delete your account, all the data that is synced with iCloud will also be deleted from the device (but not from iCloud), but will be synced back to your device when you login again.
    In order to change your Apple ID or password for your iCloud account on your computer, you need to sign out of the account from your computer first, then sign back in using your updated details. (System Preferences > iCloud, click the sign out button)
    In order to change your Apple ID or password for your iTunes account on your iOS device, you need to sign out from your iOS device first, then sign back in using your updated details. (Settings > store, scroll down and tap your ID)

  • HT201493 I have 2 iphones on the same apple id/itunes account, how do I give them different IDs?

    I have 2 iphones (mine & my wife's) on the same apple id/itunes account, how do I give them different IDs?

    I am having the same issue.
    There is no possible way Apple didn't think this the whole way thru!
    Why in the world would I want to create an new Apple ID for everyone in my family & over complicate things?!?  "Face Time" and "Messages" can tie several devices to on Apple ID driven by contact email or phone number.  I am hard pressed to believe that Find my Friends can't be set up in a similar format.
    Please help because this is frustrating me to the point of smashing an iPhone or 2!!

  • A continuous subform, how do i refer to a specific record

    Hi,
    I have a form which displays one client at a time.  Inside that i have a subform that shows every phone call ever logged for that client along with the date and time the call was made, sorted with the oldest at the top.
    Assume main form called fClient, subform is called sCalls, date and time field in sCalls is called sTime.
    From within the fClient's VBA module, how can i refer to:
    1: the date/time of the last call to that client
    2: the date/time of the call previous to the last call
    Thanks, Gordon

    You can do it very easily with a query, e.g.
    SELECT TOP 2 CallDateTime
    FROM Calls
    WHERE ClientID = Forms!fClient!ClientID
    ORDER BY CallDateTime DESC;
    In code you can establish a recordset based on the above, though be sure to concatenate the ClientID value into the string expression rather than referencing the control as a parameter.  You can then return the values from the two rows in the recordset.
    Ken Sheridan, Stafford, England

  • How to get the current JSF phase in backing bean?

    How to get the current JSF phase in backing bean?
    Edited by: jimmy6 on Nov 27, 2007 7:27 AM

    I am using phasetracker to trace it also.I want to know whether it is it render response phase. I know FacesContext.getCurrentInstance().getRenderResponse() work for normal jsf component but it will not work for qiupukit datatable. FacesContext.getCurrentInstance().getRenderResponse() will not return true in the following phase. Why?
    [ INFO] 27-11-07 16:20:21 : BEFORE RENDER_RESPONSE(6) (http-80-Processor23)
    I want the 'get' method of datatable being called in response phase to reduce the number of calling because i put the query in 'get' method there. Actually i still straggling with the best practice to code the datatable...

  • How can I refer to the PhotoShop Object library dynamically depend on the release of PhotoShop?

    Recently, I make a program, now I face a big program:
    I make the program by visual basic and photoshop script , but my client have different release of Photoshop, for example : photoshop 7.0 cs and cs2. I know every release of PhotoShop have ist own Object library, but in visual basic 6.0, I can only refer to one PhotoShop Object library. for example: if I refer to Photoshop 8.0 Object library, if my clients release of Photoshop is 7.0. there will be a error message : Run-time error '429 ( cant create object) Run-time error '430(Class does not support Automation or does not support expected interface), How can I refer to the PhotoShop Object library dynamically depend on the release of PhotoShop?
    my email is : [email protected] .
    any suggestion?

    Please read, and reply back here with information https://forums.adobe.com/thread/1499014
    -and try some steps such as changing browsers and turning off your firewall for downloads

  • How to invoke "j_security_check" in jsf page

    Hi,
    with ADF security configure in Jdeveloper11.1.1.2, it automatically generate login.html and error.html for form authentication.
    I found in login.html, the action for form is "j_security_check", and I try to customize login page with jsf page, but don't know how to invoke "j_security_check" in jsf page, there is no more action attribute within af:form and I cannot find the "j_security_check" in commandButton action Expression Build.
    Thanks in advanced.
    Best Regards,
    Bill

    Hi,
    you will have to add the login form to the JSf page wrapped in f:verbatim so it shows as part ofthe JSF page. In JSF 1.2 using f:verbatim shoucl not be require, but by experience, better is.
    If you develop and deploy on WLS, then chapter 30 of the Fusion Developer Guide has a god solution for you to build a login form in JSF completely
    http://download.oracle.com/docs/cd/E15523_01/web.1111/b31974/adding_security.htm#BABDEICH
    This does not require j_security_check at all
    Frank

  • How can I  refer an xml  Schema that was registred in Oracle xml DB

    How can I refer an xml Schema that was registred in Oracle xml DB, from other xml schema?
    I have the follow schema,:
    <?xml version="1.0" encoding="AL32UTF8"?>
    <xsd:schema targetNamespace="schemastipostasa.xsd"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb/XDBSchema.xsd"
    elementFormDefault="unqualified" version="1.0"
    attributeFormDefault="unqualified">
    <xsd:simpleType name="codigosType" xdb:SQLType="NUMBER(4)">
    <xsd:restriction base="xsd:positiveInteger" >
    <xsd:totalDigits value="4" />
    </xsd:restriction>
    </xsd:simpleType >
    <xsd:simpleType name="integerUnoType" xdb:SQLType="NUMBER(1)">
    <xsd:restriction base="xsd:int" >
    <xsd:totalDigits value="1" />
    </xsd:restriction>
    </xsd:simpleType>
    <xsd:simpleType name="condicionType" xdb:SQLType="VARCHAR2(1)">
    <xsd:restriction base="xsd:string">
    <xsd:enumeration value="S" >
    <xsd:annotation>
    <xsd:documentation>Condicion si es S</xsd:documentation>
    </xsd:annotation>
    </xsd:enumeration>
    <xsd:enumeration value="N" >
    <xsd:annotation>
    <xsd:documentation>Condicion no es N</xsd:documentation>
    </xsd:annotation>
    </xsd:enumeration>
    </xsd:restriction>
    </xsd:simpleType >
    </xsd:schema>
    I registred the schema written above with the folowwing pl*sql :
    DECLARE
    direc varchar2(2000);
    nombreArch BFILE;
    mens varchar2(2000);
    BEGIN
    direc:=uso_comun.pack_mail.fun_valor_param('TASA','DIR_DBSERVER');
    nombreArch:=bfilename(direc,'schemas_tipos_tasa.xsd');
    DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL => 'http://xmlns.oracle.com/tasa/schemas.tipos.tasa.xsd',
    SCHEMADOC => nombreArch,
    LOCAL => TRUE,
    CSID => nls_charset_id('AL32UTF8'));
    dbms_lob.CLOSE(nombreArch);
    dbms_output.put_line('salio sin cancelar');
    exception
    when others then
    mens:=sqlerrm;
    dbms_lob.CLOSE(nombreArch);
    rollback;
    raise_application_error (-20001,'en registro shcema='||mens);
    END;
    Then, I want to register the following schema, that mention de schema above:
    <?xml version="1.0" encoding="AL32UTF8"?>
    <xsd:schema targetNamespace="schema.repuesto.xsd"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:xdb="http://xmlns.oracle.com/xdb/XDBSchema.xsd"
    xmlns:tns="http://xmlns.oracle.com/tasa/schemas.tipos.tasa.xsd"
    elementFormDefault="qualified" version="1.0"
    attributeFormDefault="unqualified" >
    <xsd:element name="PRECIORENG" type="preciorepType" />
    <xsd:complexType name="preciorepType" >
    <xsd:sequence minOccurs="1" maxOccurs="unbounded">
    <xsd:element name="CODIGO_MARCA" type="tns:codigosType" />
    <xsd:element name="ORIGEN_PRECIO" type="tns:integerUnoType" />
    <xsd:element name="INGRESO_POR_FALTANTE" type="tns:condicionType" />
    </xsd:sequence>
    </xsd:complexType>
    </xsd:schema>
    But when a run the following script whith the same db-user:
    DECLARE
    direc varchar2(2000);
    nombreArch BFILE;
    mens varchar2(2000);
    BEGIN
    direc:=uso_comun.pack_mail.fun_valor_param('TASA','DIR_DBSERVER');
    -- nombreArch:=bfilename(direc,'prueba_schema_seis.xsd');
    nombreArch:=bfilename(direc,'Schema_repuesto_nuevo.xsd');
    DBMS_XMLSCHEMA.registerSchema(
    SCHEMAURL =>'http://xmlns.oracle.com/tasa/schema.repuesto.xsd',
    SCHEMADOC => nombreArch,
    LOCAL => TRUE,
    CSID => nls_charset_id('AL32UTF8'));
    dbms_lob.CLOSE(nombreArch);
    dbms_output.put_line('salio sin cancelar');
    --commit;
    exception
    when others then
    mens:=sqlerrm;
    dbms_lob.CLOSE(nombreArch);
    rollback;
    raise_application_error (-20001,'en registro shcema='||mens);
    END;
    tell me the error: ORA: 01031, insufficient privileges!!!!, what’s wrong??,

    Hi,
    To register schema, you require XDBADMIN system privilege granted to the user.
    Please verify this and retry.
    Rgds,
    Rakesh Tripathi

  • How can i refer to the parent window of the window containing an applet ?

    Hi all,
    I m stuck up with something. I have a web page say 'page1' which has a link that opens up a popup window. This popup say 'page2' window has an applet. On clicking particular pins on the applet i need to
    direct page1 to another URL & close the popup window. i hv tried this code.
    URL url = new URL(applet.getCodeBase(), path);
    AppletContext appletcontext = applet.getAppletContext();
    appletcontext.showDocument(url, "content");
    JSObject win = JSObject.getWindow(applet);
    win.eval("alert(\"Do u wnat to close!\");");
    win.eval("window.close()");
    This code opens up another window on click of the pin, & shows an alert before closing the popup window. On using
    appletcontext.showDocument(url, "_parent"); or
    appletcontext.showDocument(url, "_top");
    The window containing applet gets refreshed with the URL but not page1.
    How can i refer so to page1 from the applet.

    You don't show your code for what parent or top are, but in an
    applet, you must stick with relative links. Once you have the
    appletcontext, use a relative path from there:
    In the snippet below, docName is a relative path, i.e. ../up/above
       * Displays the specified document in the Web browser.
       * @param docName String pathname of document to download from Webserver
       * @return void
      private void fetchDocument(String docName) {
         AppletContext ctx = getAppletContext();
         java.net.URL serverURL = getDocumentBase();
         java.net.URL codeURL   = getCodeBase();
         java.net.URL docURL = null;
         try {
            docURL = new java.net.URL(codeURL, docName);
         catch (java.net.MalformedURLException err) {
            System.out.println("unable to compute URL from (" + serverURL + ", " +
                               docName + ")");
         if(this.bDebug)
           System.out.println("Open document: " + docURL.toString());
         ctx.showDocument(docURL);
      }

  • How to you refer to a function in another function in a cfc

    HI,
    How to you refer to a function in another function in a cfc like so
    <cffunction name="getApplicationConstants" access="remote" returntype="struct">
             <cfset flash.result.users = [the result from the getUsers function]>
        <cfreturn flash.result>
    </cffunction>
    <cffunction name="getUsers" access="remote" returntype="query">
            <cfquery name="q" datasource="#datasource#">
                select     c.*
                from    USERS as c    WHERE looksLikeUserIsDeleted = 'False'
                AND userPrivileges = 1
                ORDER BY fullName
            </cfquery>
            <cfset flash.result = q>
            <cfreturn flash.result>
    </cffunction>

    Hi, Nikos,
    If the CFCs are in the same directory, you could do the following:
    CFCA
    <cfcomponent>
    <cffunction name="getApplicationConstants" access="remote" returntype="struct">
        <cfset flash.result.users = cfcB.getUsers() />
        <cfreturn flash.result>
    </cffunction>
    </cfcomponent> 
    CFCB
    <cfcomponent>
    <cffunction name="getUsers" access="remote" returntype="query">   
            <cfquery name="q" datasource="#datasource#">
                select     c.*
                from    USERS as c    WHERE looksLikeUserIsDeleted = 'False'
                AND userPrivileges = 1
                ORDER BY fullName       
            </cfquery>
            <cfset flash.result = q>
            <cfreturn flash.result>
    </cffunction>
    <cfcomponent>
    If the CFCs were in different directories, the cfset expression in CFCA would be this:
    <cfset flash.result.users = path.to.cfc.cfcB.getUsers() />
    Where I have path.to.cfc, you would use either a mapping from CF Admin or the hierarchy of folders to the CFC from the web root.
    Does that help?

Maybe you are looking for

  • Why is my Mac storing graphics and photos from the web in iPhoto?

    How can I prevent my Mac from downloading graphics and photos from the web?   How do I remove the thousands of images that the Mac moved into iPhoto when I browse the web? 

  • How to create round charts in Pages?

    Hi community, I'm working on my curiculum vitae at the moment and wanted to add some charts to it for better visualisation. Since Pie Charts don't look that great in my oppinion i searched a bit at google and discovered a nice looking template (sadly

  • Custom Login Module from OAS 10.1.3.1

    This may be more of a JDEV question as it has less to do with configuration... Will a custom login module written for OAS 10.1.3.1 work in Web Logic? Or will I have to scrap my current custom login module?

  • QM Block not triggered  via EDI orders

    Hello All, Please help me with this problem "QM block not triggered via EDI Orders". Sales Orders will be created using IDOC. When the sales orders was displayed using VA02, goto >> items >> schedule lines, there's no QM status violated being display

  • Illustrator to Bridge needs PDF? WHY?

    1. Why does Bridge need Illustrator files to be saved as PDF files? "PDF Compatible File" ticked in the save menu. 2. Why does saving with this info take so long, even on decent fast modern systems? 3. Why does Bridge not consistently render the Illu