Javascript to JSF

Hi,
I am new to develop web application and this is my
first time to use JSF and JavaScript. Currently I am
developing a web application by using JSF. Meanwhile,
i would like to use javascript for the popup calendar for user to
input the date.
This is the input box of JSF page which i would like
to get the endDate from the javaScript but i have no
idea on how to get the value from the popup window.
<h:inputText styleClass="inputText" id="text3"
value="#{requestScope.endDate}"
onclick="cal1xx.select(document.forms[0].date1xx,'anchor1xx','MM/dd/yyyy');
return false;"  >
</h:inputText>Below is the html code which can create a popup window
and let user choose a date and put into the input box.
<SCRIPT LANGUAGE="JavaScript" ID="jscal1x">
var cal1x = new CalendarPopup("testdiv1");
</SCRIPT>
<INPUT TYPE="text" NAME="date1x" VALUE="" SIZE=25>
<A HREF="#" onClick="cal1x.select(document.forms[0].date1x,'anchor1x','MM/dd/yyyy'); return false;"  NAME="anchor1x" ID="anchor1x">select</A>The anchor tag MUST contain both NAME and ID attributes which are the
same. For example:
<A NAME="test" ID="test"> </A>However, in jsf page <h:inputText ></h:inputText> it
does not allow me to use the tag NAME. Or does it have
other way to get the anchor?
Thanks in advance for your help. Hope to hear from you
soon.

thanks for your clue, but i fail to solve the problem after trying out few times.
The problem for me is want to get the data which generated from JS to a JSF page. The JavaScript using anchor and after that point to the NAME which is in the HTML INPUT tag
<INPUT TYPE="text" NAME="cal1xx" VALUE="" >
<A HREF="#" onClick="cal1x.select(document.forms[0].cal1xx,'anchor1x','MM/dd/yyyy'); return false;"  NAME="anchor1x" ID="anchor1x">select</A>the onClick command there will point the cal1xx to the INPUT there.
But if i put the id of the <h:inputText id="endDate"> into the onClick="cal1x.select(document.forms[0].endDate,'anchor........
it will not works anymore.
Emm... do you have some idea on creating a popup calendar by using JSP? or JSF?
thx

Similar Messages

  • Generated javascript by JSF doesn't works with IE

    Hi Everyone!!!
    I Have a big problem, the jaavascript code generated by JSF doesn't
    works using IE, I used a h:commanLink with actionListener to a funciton
    in the backing bean, and I use two f:params to send the parameter of an
    specific element to show its details, the problem is taht the
    javascript code generated shows an error: "
    'documents.forms.form.form:_idcl' is null or is not an object " or "
    'elements.idVar' is null or is not an object ". I'm not using MyFaces,
    or something similar because the application has a part built in
    ArcgisServer, and it 's not compatible with Myfaces, so I needed to use
    JSf only...
    Please I hope an answer, it has a big problem!!!
    it is the code of the jsp
    <code><h:commandLink actionListener="#{consultaEstadisticasMB.detalleEstadistica}">
    <f:param name="idVar" value="#{consultaEstadisticasMB.idColumna3}"/>
    <f:param name="idMun" value="#{registro[0]}" />
    <h:outputText title="#{consultaEstadisticasMB.columna3}" id="itColumna3" value="#{registro[2]}" />
    </h:commandLink>
    </code>

    Minor nit: MyFaces is JSF, an implementation at least, as is Mojarra, which I assume is what you mean. :)ye, MyFaces is an implementation... but at this time, we�re using "JSF 1.1.02 - Reference Implementation"...
    Now, I have noticed that is a problem of jsf implementation so i have tried to do the work in another way, usign outputLink, nad creating a new backing bean for the details page.. altough I'm having problems, this is what i'm trying to do:
    <h:outputLink value="/ConsultaEstadisticasGeo/detalleEstadisticas.jsf?idVar=#{consultaEstadisticasMB.idColumna3}">
              <h:outputText title="#{consultaEstadisticasMB.columna3}"id="itColumna3" value="#{registro[2]}" />
    </h:outputLink>but it shows me an error...
    GRAVE: Servlet.service() para servlet Faces Servlet lanz� excepci�n
    java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    And I don't kwon why. If you could help me, I would been so grateful

  • JAVASCRIPT AND JSF PROBLEM REFRESHING PAGE PROBLEM

    Hello everyone, I am currently using visual JSF and javascript to to disable a fileupload component when a radio button is clicked. I don't have any problems getting it to work if I need to disable a button, a textfield or other visual JSF components. For some reason, i can't disable the fileupload component and I get this error when the JAVASCRIPT is called:
    Error: document.getElementById("form1:fileUpload1").refresh is not a function
    Source File: http://localhost:8080/TestSingleEvent/theme/com/sun/webui/jsf/suntheme4_2-080320/javascript/webui.js
    Line: 22
    My javascript code is the following:
    document.getElementById("form1:fileUpload1").refresh("form1:radioButton1");return false;
    I would appreciate some help here. Why is it that when I replace the fileUpload with i.e a textfield i don't get errors..
    Is it something to do with the webui.js ?
    Many thanks.

    There is no such thing as refresh() in the [DOM element|http://developer.mozilla.org/en/DOM/element]. How did you come to this? Did you a wild guess in the around without reading the docs? Don't do that.
    What exactly do you want to achieve? Reset its value? Then set the 'value' property to null. Disable the element? Then set the 'disabled' property to true.
    I've been helpful enough with this offtopic question. If you still stucks, please continue at a Javascript oriented forum. There's one at under each webdeveloper.com.

  • How to apply a simple javascript into JSF

    Hi everyone. This is my first time using JSF and i am abit confuse in applying some simple javascript into my JSF. Actually, i just want to add a simple function that is to disable user from input some certain textfield (h:inputText) based on the selection in the combo box (h:selectOneMenu).
    The javascipt that i would like to apply in the JSF coding is shown as below:-
    <HTML>
    <TITLE>Example of onChange Event Handler</TITLE>
    <HEAD>
    <SCRIPT LANGUAGE="JavaScript">
    function textField()
    if(document.myform.mcDonald.value=="disable")
    document.myform.data.disabled=true;
    if(document.myform.mcDonald.value=="enable")
    document.myform.data.disabled=false;
    </SCRIPT>
    </HEAD>
    <BODY>
    <H3>Example of onChange Event Handler</H3>
    <form name="myform">
    <SELECT NAME="mcDonald" onChange="textField()">
    <OPTION VALUE="enable">Enable
    <OPTION VALUE="disable">Disable
    </SELECT>
    <input type="text" name="data" value="10" size=10 disabled="true" >
    </form>
    </BODY>
    </HTML>

    You need to use the id's of the components in the hierarchy. This is actual working code:
    // Javascript
              function actionedStatus_onchange(formObj, fieldValue) {
                   formObj.elements['foureye:tabExceptions:unresolvedOnly'].disabled = (fieldValue != 'all');
                   formObj.elements['foureye:tabExceptions:unresolvedOnly'].checked = (fieldValue == 'all');
    // JSF
                   <x:selectOneMenu id="actionedStatus" styleClass="detailBondField" value="#{exceptionsBean.actionedStatus}"
                             onchange="actionedStatus_onchange(this.form, this.value)">
                        <f:selectItems value="#{lookupBean.actionedStatusList}"/>
                   </x:selectOneMenu>
    In this case, the root component form is 'foureye' (a subview), followed by 'tabExceptions' (a form), followed by a checkbox 'unresolvedOnly' that I want to manipulate. Here I am disabling the checkbox and setting the value dependent on the value of the selectOneMenu

  • How to use ocx with javascript in jsf page

    Hello,
    Please i create a jsf page which purpose is to scan.
    I used in a source of my jsf page an OCX with object tag like
    <OBJECT ID="Ranger"
    CLASSID="CLSID:1C5C9095-05A8-11D4-9AF9-00104B23E2B1">
    </OBJECT>
    i wrote my functions which use this ocx in javascript. Function that i call with clientlistener rear adf button
    but it doesn't work
    Could you please help me please VERY IMPORTANT

    This my html code:
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportNewState(newState,previousState)>  
    // Transport new state, fired every time the State changes on the control
    // input params , are the new state and the previous state
    //alert(newState);
    var RangerTransportStates = {TransportUnknownState: -1, TransportShutDown: 0, TransportStartingUp: 1,
                                  TransportChangeOptions: 2, TransportEnablingOptions: 3, TransportReadyToFeed: 4,
                                  TransportFeeding: 5, TransportExceptionInProgress:6, TransportShuttingDown: 7};
    if(newState == RangerTransportStates.TransportShutDown)
          document.getElementById('StartRanger').disabled = false;
          document.getElementById('EnableRanger').disabled = true;
          document.getElementById('StopFeeding').disabled = true;
          document.getElementById('StartFeeding').disabled = true;
          document.getElementById('ChangeOptions').disabled = true;
          document.getElementById('Shutdown').disabled = true;     
          document.getElementById('UserInstructions').innerHTML = "Press 'Startup Ranger' to initialize the Ranger control"
    if(newState == RangerTransportStates.TransportChangeOptions)
          document.getElementById('StartRanger').disabled = true;
          document.getElementById('StartFeeding').disabled = true;
          document.getElementById('EnableRanger').disabled = false;
          document.getElementById('Shutdown').disabled = false;
          document.getElementById('UserInstructions').innerHTML = "<b>Ranger Started</b> <br> Press 'Enable Ranger' to enable the current Ranger Options and prepare to start feeding"
    if(newState == RangerTransportStates.TransportReadyToFeed)
          document.getElementById('EnableRanger').disabled = true;
          document.getElementById('StopFeeding').disabled = true;
          document.getElementById('StartFeeding').disabled = false;
          document.getElementById('ChangeOptions').disabled = false;
          document.getElementById('Shutdown').disabled = false;
          document.getElementById('UserInstructions').innerHTML = "<b>Ready to feed </b><br> Press 'Start Feeding' to start Ranger Feeding checks from main hopper"
    if(newState == RangerTransportStates.TransportFeeding)
          document.getElementById('StartFeeding').disabled = true;
          document.getElementById('ChangeOptions').disabled = true;
          document.getElementById('Shutdown').disabled = true;
          document.getElementById('StopFeeding').disabled = false;     
          document.getElementById('UserInstructions').innerHTML = "<b>Feeding... </b><br> Press 'Stop Feeding' to stop Ranger from Feeding checks"
    getstatus();
    </SCRIPT> 
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportChangeOptionsState(previousState)>  
    //Fired when Ranger reaches the change option state, input params are previous state
    getstatus();
    </SCRIPT> 
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportReadyToFeedState(previousState)>  
    //Fired when ranger is ready to feed the next item
    getstatus();
    </SCRIPT> 
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportFeedingStopped(reason,itemsFed,itemsrequested)>  
    //Fired when feeding has stopped
    getstatus();
    </SCRIPT> 
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportItemInPocket(itemID)>  
    //Fired when the item has been fed into the pocket
    var RangerSides = {TransportFront: 0, TransportRear: 1};
    var RangerImageColorTypes = {ImageColorTypeBitonal:0, ImageColorTypeGrayscale: 1, ImageColorTypeColor: 2};
    // Note: SaveImageToFile() below is used to save gray scale images.  Please verify that 'NeedFrontImage2' and
    //       'NeedRearImage2' are set to 'true' in the GenericOptions.ini file.  If bitonal images are to be saved,
    //       please set 'NeedFrontImage1'/'NeedRearImage1' to 'true' before calling SaveImageToFile() for bitonal images.
    document.getElementById('MICR').innerHTML = 'MICR: ' + Ranger.GetMicrText(1);
    temp = Ranger.SaveImageToFile(RangerSides.TransportFront, RangerImageColorTypes.ImageColorTypeGrayscale, "C:\\test\\Testfront.jpg");
    temp = Ranger.SaveImageToFile(RangerSides.TransportRear, RangerImageColorTypes.ImageColorTypeGrayscale,"C:\\test\\Testback.jpg");
    //Here you could check to see if the images were saved, putting alternate
    //text in place of the image if they werent saved.
    document.getElementById('PIC').innerHTML = '<img height=200 width=400 src=' + '"Testfront.jpg">' + '<br>' + '<img height=200 width=400 src=' + '"Testback.jpg">';
    getstatus();
    </SCRIPT> 
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportNewItem()>  
    // Fired when a new item has entered the track
    getstatus();
    </SCRIPT> 
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportShutDownState(currentState,previousState)>  
    //Fired when the Ranger control has been shutdown
    getstatus();
    </SCRIPT> 
    <SCRIPT LANGUAGE=javascript FOR=Ranger EVENT=TransportSetItemOutput(itemID)>  
    //fired when the item is ready to have params set(pocketing decisions)
    getstatus();
    </SCRIPT> 
    <!-- End of Events ------------- -->
    <SCRIPT LANGUAGE="javascript">
    function getstatus()
         document.getElementById('Status').innerHTML = 'Status: ' + Ranger.GetTransportStateString();
    </SCRIPT>
    </head>
    <body>
    <OBJECT ID="Ranger"
    CLASSID="CLSID:1C5C9095-05A8-11D4-9AF9-00104B23E2B1">
    </OBJECT>
    <div id="container">
         <div id="banner" >
         </div>
         <div id="left">
              <h2>Ranger Control Buttons</h2>
              <br><div id="Status">Status:</div><br>
              <input class="controlbutton" id="StartRanger" type=button value="Startup Ranger" onclick="Ranger.Startup();">
              <input class="controlbutton" id="EnableRanger" disabled type=button value="Enable Ranger" onclick="Ranger.EnableOptions();">
              <input class="controlbutton" id="StartFeeding" disabled type=button value="Start Feeding" onclick="Ranger.StartFeeding(0,0);">
              <input class="controlbutton" id="StopFeeding" disabled type=button value="Stop Feeding" onclick="Ranger.StopFeeding();">
              <input class="controlbutton" id="ChangeOptions" disabled type=button value="Change Options" onclick="Ranger.PrepareToChangeOptions();">
              <input class="controlbutton" id="Shutdown" disabled type=button value="Shutdown Ranger" onclick="Ranger.Shutdown();">
         </div>
         <div id="content">
              <div id="UserInstructions">Press 'Startup Ranger' to initialize the Ranger control</div>
              <br>
              <div id="MICR"></div>
              <br>
              <div id="PIC"></div>
         </div>
         <div id="footer"><h1>Ranger Control</h1></div>
    </div>
    them jsf code:
    <f:view>
    <OBJECT ID="Ranger"
        CLASSID="CLSID:1C5C9095-05A8-11D4-9AF9-00104B23E2B1">
    </OBJECT>   
      <af:document id="d1" title="Fiche Bordereau">
        <af:messages id="m1"/>
        <af:form id="f1">
          <af:pageTemplate viewId="/tempCompens.jspx" id="pt1">
           <af:resource type="javascript">
            // Transport new state, fired every time the State changes on the control
            // input params , are the new state and the previous state
            //alert(newState);
            var RangerTransportStates = {TransportUnknownState: -1, TransportShutDown: 0, TransportStartingUp: 1,
                                  TransportChangeOptions: 2, TransportEnablingOptions: 3, TransportReadyToFeed: 4,
                                  TransportFeeding: 5, TransportExceptionInProgress:6, TransportShuttingDown: 7};
            ok =false;
            var i = 0;
            if(newState == RangerTransportStates.TransportShutDown)
                document.getElementById('btn_demarre').disabled = false;
                document.getElementById('btn_active').disabled = true;
                document.getElementById('btn_arretscan').disabled = true;
                document.getElementById('btn_scan').disabled = true;
                document.getElementById('btn_changetat').disabled = true;
                document.getElementById('btn_arret').disabled = true;
                document.getElementById('UserInstructions').value = "Appuyer sur Demarrer pour initiliser le scanner"
            if(newState == RangerTransportStates.TransportChangeOptions)
                document.getElementById('btn_demarre').disabled = true;
                document.getElementById('btn_scan').disabled = true;
                document.getElementById('btn_active').disabled = false;
                document.getElementById('btn_arret').disabled = false;
                document.getElementById('UserInstructions').value = "Demarrage... Appuyer sur Activer pour preparer le scanning "
                ok = false;
            if(newState == RangerTransportStates.TransportReadyToFeed)
                document.getElementById('btn_active').disabled = true;
                document.getElementById('btn_arretscan').disabled = true;
                document.getElementById('btn_scan').disabled = false;
                document.getElementById('btn_changetat').disabled = false;
                document.getElementById('btn_arret').disabled = false;
                document.getElementById('UserInstructions').value = "Pret a scanner.   Appuyer sur Scanner pour lancer le scanning"
                ok = true;
            if(newState == RangerTransportStates.TransportFeeding)
                document.getElementById('btn_scan').disabled = true;
                document.getElementById('btn_changetat').disabled = true;
                document.getElementById('btn_arret').disabled = true;
                document.getElementById('btn_arretscan').disabled = false;
                document.getElementById('UserInstructions').value = "Scanning...  Appuyer sur Arret scanning pour stopper le scanning"
            getstatus();
           </af:resource>
           <af:resource type="javascript">
            //Fired when the item has been fed into the pocket
                var RangerSides = {TransportFront: 0, TransportRear: 1};
                var RangerImageColorTypes = {ImageColorTypeBitonal:0, ImageColorTypeGrayscale: 1, ImageColorTypeColor: 2};
            //alert(Ranger.GetGenericOptionFileName());
                Ranger.SetGenericOption("OptionalDevice","NeedFrontImage1",true);
                Ranger.SetGenericOption("OptionalDevice","NeedRearImage1",true);
                document.getElementById('cmc7').value = 'CMC7= '+Ranger.GetMicrText(1);
                var cmc7 = trim(Ranger.GetMicrText(1));
                cmc7 = cmc7.replace(" ","_");
                cmc7 = cmc7.replace(" ","_");
            //cmc7 = cmc7.substring(0,15);
                cmc7R = cmc7+"_R.jpg";
            //alert(Ranger.GetImageAddress(RangerSides.TransportFront, RangerImageColorTypes.ImageColorTypeGrayscale))
                function trim(myString)
                    return myString.replace(/^\s+/g,'').replace(/\s+$/g,'')
                temp = Ranger.SaveImageToFile(RangerSides.TransportFront, RangerImageColorTypes.ImageColorTypeGrayscale, "C:\\Documents and Settings\\Koffi Ernest\\Mes documents\\NetBeansProjects\\Scan-project\\web\\"+cmc7R);
                window.onload = function()
                  document.getElementById("verso").src = monfichierV();
                function monfichierR()
                //  nomfichier = nomfichier+"_R.jpg";
                    var nomfichier = trim(Ranger.GetMicrText(1))+"_R.jpg";
                    return  nomfichier
                cmc7V = cmc7+"_V.jpg";
                temp = Ranger.SaveImageToFile(RangerSides.TransportRear, RangerImageColorTypes.ImageColorTypeGrayscale,"C:\\Documents and Settings\\Koffi Ernest\\Mes documents\\NetBeansProjects\\Scan-project\\web\\"+cmc7V);
                window.onload = function()
                    document.getElementById("verso").src = monfichierV();
                function monfichierV()
                    var nomfichierV = trim(Ranger.GetMicrText(1))+"_V.jpg";
                    return nomfichierV
                function getRImageUrl(img)
                    var imageSrc = trim(Ranger.GetMicrText(1))+"_R.jpg";
                    if(img.src != imageSrc)
                    // don't get stuck in an endless loop
                    img.src = imageSrc;
                function getVImageUrl(img)
                 var imageSrc = trim(Ranger.GetMicrText(1))+"_V.jpg";
                 if(img.src != imageSrc)
                 { // don't get stuck in an endless loop
                  img.src = imageSrc;
            document.getElementById('recto').source = cmc7R;
            document.getElementById('verso').source = cmc7V;
            getstatus();
           </af:resource>
            <af:resource type="javascript">
                 document.getElementById('status').value = Ranger.GetTransportStateString();
            </af:resource>
            <f:facet name="temp">
              <af:panelSplitter id="ps1" splitterPosition="329"
                                inlineStyle="width:709px;">
                <f:facet name="first">
                  <af:panelGroupLayout layout="scroll"
                                       xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                                       id="pgl5">
                    <af:panelGroupLayout id="pgl1">
                      <af:outputText value="Saisie des informations du bordereau"
                                     id="ot1"
                                     inlineStyle="font-size:small; font-family:inherit; color:Gray; font-weight:bold;"/>
                    </af:panelGroupLayout>
                    <af:panelFormLayout id="pfl1">
                      <f:facet name="footer">
                        <af:panelGroupLayout id="pgl4" layout="horizontal">
                          <af:commandButton text="Annuler" id="cb4"/>
                          <af:spacer width="5" height="10" id="s14"/>
                          <af:commandButton text="Scanner" id="cb5"
                                            action="success"/>
                        </af:panelGroupLayout>
                      </f:facet>
                      <af:spacer width="10" height="30" id="s2"/>
                      <af:panelGroupLayout id="panelGroupLayout1"
                                           layout="horizontal" valign="middle">
                        <af:inputText label="N° de compte                   " id="it1"/>
                        <af:spacer width="10" height="10" id="s16"/>
                        <af:commandButton text="..." id="cb3"/>
                      </af:panelGroupLayout>
                      <af:spacer width="5" height="3" id="s12"/>
                      <af:panelGroupLayout id="pgl2" layout="horizontal"
                                           valign="middle">
                        <af:inputText label="Nom du client         " id="it3"/>
                      </af:panelGroupLayout>
                      <af:spacer width="5" height="3" id="s17"/>
                      <af:panelGroupLayout id="pgl11" layout="horizontal"
                                           valign="middle">
                        <af:inputText label="N° bordereau    " id="it4"/>
                        <af:spacer width="5" height="10" id="s11"/>
                        <af:commandButton text="New" id="cb1"/>
                        <af:spacer width="2" height="10" id="s13"/>
                        <af:commandButton text="Find" id="cb2"/>
                      </af:panelGroupLayout>
                      <af:spacer width="5" height="3" id="s18"/>
                      <af:panelGroupLayout id="pgl3">
                        <af:inputText label="Nbre de chèque" id="it2"/>
                        <af:spacer width="5" height="3" id="s19"/>
                        <af:inputDate label="Date d'operation                  " id="id1"/>
                      </af:panelGroupLayout>
                      <af:spacer width="1000" height="10" id="s1"/>
                    </af:panelFormLayout>
                  </af:panelGroupLayout>
                </f:facet>
                <f:facet name="second">
                  <af:panelGroupLayout layout="scroll"
                                       xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
                                       id="pgl6">
                    <af:outputText value="Resultat scanning" id="ot2"
                                   inlineStyle="font-size:small; font-weight:bold; color:Gray;"/>
                    <af:panelTabbed id="pt2"
                                    inlineStyle="height:498px; width:680px;">
                      <af:showDetailItem text="Scanning" id="sdi1">
                        <af:panelSplitter id="ps2" splitterPosition="103"
                                          inlineStyle="width:433px; height:436px;">
                          <f:facet name="first">
                            <af:panelGroupLayout id="pgl7" layout="vertical">
                              <af:outputText value="Liste de contrôles" id="ot3"
                                             inlineStyle="font-weight:bold; color:Gray;"/>
                              <af:spacer width="10" height="10" id="s20"/>
                              <af:outputText id="status"/>
                              <af:spacer width="10" height="10" id="s8"/>
                              <af:commandButton text="Demarrer      "
                                                id="btn_demarre">
                                <af:clientListener type="click"
                                                   method="Ranger.Startup()"/>
                              </af:commandButton>
                              <af:spacer width="10" height="10" id="s7"/>
                              <af:commandButton text="Activer              "
                                                id="btn_active"
                                                disabled="true">
                                <af:clientListener method="Ranger.EnableOptions()"
                                                   type="click"/>
                              </af:commandButton>
                              <af:spacer width="10" height="10" id="s6"/>
                              <af:commandButton text="Scanner       "
                                                id="btn_scanne"
                                                disabled="true">
                                <af:clientListener method="Ranger.StartFeeding(0,0)"
                                                   type="click"/>
                              </af:commandButton>
                              <af:spacer width="10" height="10" id="s3"/>
                              <af:commandButton text="Arrêt Scan   "
                                                id="btn_arretscan"
                                                disabled="true">
                                <af:clientListener method="Ranger.StopFeeding()"
                                                   type="click"/>
                              </af:commandButton>
                              <af:spacer width="10" height="10" id="s4"/>
                              <af:commandButton text="Changer Etat"
                                                id="btn_changetat"
                                                disabled="true">
                                <af:clientListener method="Ranger.PrepareToChangeOptions()"
                                                   type="click"/>
                              </af:commandButton>
                              <af:spacer width="10" height="10" id="s5"/>
                              <af:commandButton text="Arrêter         "
                                                id="btn_arret"
                                                disabled="true">
                                <af:clientListener method="Ranger.Shutdown()"
                                                   type="click"/>
                              </af:commandButton>
                            </af:panelGroupLayout>
                          </f:facet>
    ....Edited by: nesta on 21 juil. 2010 07:07

  • Question accessing a h:outputText element from Javascript from JSF portlet

    I have a <h:outputText element that I'd like to update the value from javascript.
    However the element is not found in the form. I can access all the other form elements,
    just not <h:outputText elements. Does anyone know how to get around this?
    The code is running in a JSF portlet on WLP 10.3.2, Code snippets below:
    JSP
    <f:view>
    <h:form id="updaterForm">
    <h:panelGroup layout="block" id="pg_geoWrapper">
    <table id="t_geoFields">
    <tr><td><h:outputText id="ot_geoStatus" value="Status:"/></td></tr>
    </table>
    </h:panelGroup>
    </h:form>
    </f:view>
    When a button is clicked the javascript is called
    JAVASCRIPT
    function displayProperComponents(myForm) {
    var statusLabelId = null;
    for(i=0; i<myForm.elements.length; i++) {
    if (myForm.elements.id.indexOf("ot_geoStatus")>=0){
    statusLabelId = myForm.elements[i].id;
    if (document.getElementById(statusLabelId) != null){
    document.getElementById(statusLabelId).innerHTML = '';

    There are more possibilities as well. If you depend it on for example the User's rights/groups, then you can also do for example:
    rendered="#{user.admin}" // getter = public boolean isAdmin()
    rendered="#{user.groupName == 'admin'}" // getter = public String getGroupName()
    rendered="#{user.groupId > 1}" // getter = public int getGroupId()
    rendered="#{fn:contains(user.groups, 'admin')}" // getter = public String[] getGroups() or public List<String> getGroups()
    etc..I think it's after all just a matter of learning about the capabilities of EL a bit more.

  • How to use javascript for jsf containg t:htmlTags instead of panel grids

    Hi,
    i tried out validation in the following manner:
    function valid(form){
    alert(" 1:Entered valid function ");
    var varCritical1=document.form["form:critical1"].checked;
    var varHigh1=document.form["form:high1"].checked;
    if (varHigh1&&varCritical1){
    alert("Select only one option");
    document.form["form:critical1"].focus();
    document.form["form:high1"].focus();
    return false;
    return true;
    ====== the jsf code for the above is:
    <t:htmlTag value="td" style="border: 1px solid;">
    <h:commandButton id="commit" value="Commit all Changes" action="commit" styleClass="submit-button"
                                  onClick="return valid(this.form)" />
    </t:htmlTag>
    ======
    could anyone suggest me how to do this validation..
    faster reply is appreciated
    -Thanks,
    Soumya Desu

    When writing JS and you're new to JSF (so new that you don't know out of head which HTML a JSF component generate), you need to base the JS code on the generated HTML output, not on the JSF source code.
    For problems and/or support with writing JS code, please consult a JS forum. There are ones at webdeveloper.com and dynamicdrive.com. Please keep in mind that JSF source code is completely irrelevant for the JS forum users (and actually also for you), concentrate on and share the generated HTML output.

  • Javascript and JSF

    I am using javascript to try and populate a page with data from a row that is double-clicked.
    I am using the following javascript to output the contents of the row but i want the contents of the row to populate another page when it is double clicked. Can anyone help with this? Or suggest what i change in the javascript i am using?
    Thanks.
    <script>
    function myhandler(){
    alert(value="#{RouteHandler.carrierCode}");
    alert(value="#{RouteHandler.departureAirport}");
    alert(value="#{RouteHandler.arrivalAirport}");
    this.style.backgroundColor='#ffffff';
    </script>
    I am calling the javascript function in the following dataTable:
    t:dataTable id="routeList" value="#{RouteHandler.routeList}" var="rowElement" cellspacing="0" cellpadding="3"
    ondblclick="javascript:myhandler()" border="0" headerClass="listhead" columnClasses="listresults" bgcolor="#FFFFFF">
    <t:column width="104">
    <h:outputText value="#{rowElement.carrierCode}" />
    </t:column>
    <t:column width="165">
    <h:outputText value="#{rowElement.departureAirport}" />
    </t:column>
    <t:column width="920">
    <h:outputText value="#{rowElement.arrivalAirport}" />
    </t:column>
    </t:dataTable>

    If you want javascript itself, then how about this:
         function testDblClick() {
              var evt = window.event;
              var destElement = evt.srcElement;
              if(destElement.tagName == 'BODY') return;
              var parentEle = destElement.parentNode;
              while(parentEle.tagName != "TR") {
                   parentEle = parentEle.parentNode;
                   if(parentEle == null) break;
              var msg = '';
              var childNode = null;
              for(var i=0;i<parentEle.childNodes.length;++i) {
                   childNode = parentEle.childNodes;
                   msg += parentEle.childNodes[i].innerHTML + " | ";
              if(msg != '') alert(msg);
    code}
    At the end of you JSP page inculde this code:
    document.ondblclick = testDblClick;

  • Javascript confirm form jsf

    Hello,
    In my project I have to search for a person in two tables A and B. The search method in the backing bean should do something like this: search in table A, then in case the person was not found, prompt the user for confirmation on searching in table B.
    How can this be done with jsf?
    Thank you,
    Ioana.

    I'm sorry. I was not clear. I know I can use javascript from jsf. I want to use javascritpt from the backing bean.
    So in the action method I search table A, then ask for confirmation and proceed with table B or not, depending on the user's choice.
    Ioana.

  • Javascript to check only one of the two checkboxes in JSF

    Hi,
    I have this working in HTML, but when trying to simulate the same in JSF, I get error.
    <input id="checkbox1" type="checkbox" onClick="selecionatudo(true,1)"/>
    <input id="checkbox1" type="checkbox" onClick="selecionatudo(true,2)"/>
    Javascript
    function selecionatudo(check,n) {
    var frm = document.getElementById('form1');
    for (i=0;i<2;i++) {
    if (check) {
    frm.checkbox1.checked=false;
    frm.checkbox1[n-1].checked=true;
    JSF checkboxes
    A<h:selectBooleanCheckbox id="checkbox1" onclick="selecionatudo(true,1)"/></h:selectBooleanCheckbox>
    B<h:selectBooleanCheckbox id="checkbox2" onclick="selecionatudo(true,2)"/></h:selectBooleanCheckbox>
    Since in <h:selectBooleanCheckbox I cannot use the id attribute which can hold duplicate values, I get an error, using the above method.
    Also, <h:selectBooleanCheckbox cannot have a name attribute .(having which, I can use the above Javascript to work)
    Please help me.

    Hi!
    I think that:
    If you have pairs of checkboxes to make actions, you can try to set id in Jsf like this " checkBoxA1" and "checkBoxA2".
    Then in JavaScript, you can get de string "checkBoxA" and build the two id's, adding and "1" and "2".
    Later, you can do that you want.
    But, I think that in JavaScript across Jsf, you can't use "frm.checkbox1", i think that you must use: "document.getElementById("checkbox1").
    I'm a starter in Jsf and very bad with English, but I hope that it help you!
    Regards!

  • JSF Ajax script error in IE8 while session times out

    We have JSF 1.1, Richfaces a4j 3.1.6 in our application.
    We get an empty page with the script error when the session timesout. When we make any ajax request after the session expires, the script error pops up. We noticed this only in IE8.
    I get this error on IE8 for session timeout.
    Webpage error details
    User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; MS-RTC LM 8)
    Timestamp: Fri, 28 May 2010 15:26:37 UTC
    Message: Object doesn't support this property or method
    Line: 83
    Char: 390
    Code: 0
    URI: http://localhost:8080/sir/loan/a4j_3_1_6.GAorg.ajax4jsf.javascript.AjaxScript.jsf
    Appreciate your help.

    Upgrade your ancient technology. JSF 1.2.12 at the least with Richfaces 3.3.3.
    OR
    accept that your ancient technology will have flaws and live with them.

  • How can Client side validate in jsf ?

    Hello,
    This is mohan, I am newly for jsf. can you please anyone tell me, how to clinet side validate in jsf?
    thanks Mohan

    Use JavaScript.
    JSF does not do client side validation. It is only a server-side technology.
    CowKing

  • XML Parsing Error: duplicate attribute in Firefox

    Hello,
    I recently switched from a JSF 1.2 RI nightly build from March to the 1.2_01 SNAPSHOT from 5/5/06 available in the maven repository:
    https://maven-repository.dev.java.net/repository/javax.faces/jars/
    Upon doing so, Firefox stopped rendering certain pages complaining of dupicate attributes (IE doesn't seem to care). The duplicate attributes are onclick attributes of <h:commandButton/> generated <input/> tags.
    The background is that we have a number of <h:commandButton> tags that once submitted forms as part of JSF actions, but were modified to call JavaScript (non-JSF integrated) instead (type="button" onclick="someJavaScriptFunc()"). As this is the case, the problem has been easily avoided by changing the <h:commandButton/> tags to regular html <input/> tags.
    My question is whether the rendering of two onclick attributes per <h:commandButton type="button"/> tags is a bug that should be reported, or a result of user error.
    I am also using Facelets 1.1.4 in JBoss AS 4.0.3sp1.
    Thanks for the help,
    Jonn

    No, my expectations are not unmet. Being new to JSF 1.2 RI, I thought it best to ask about possible user error before reporting a bug.
    Not surprised that the same error appears in app server 9 as it looks like it contains a JSF snapshot from a few days before the one I'm using.
    I just tested the nightly from 6-2-2006 and the duplicate attribute problem appears fixed, so no need to open an issue. tromanow, you might want to grab these jars from the jsf java.net site:
    https://javaserverfaces.dev.java.net/servlets/ProjectDocumentList?folderID=1703&expandFolder=1703&folderID=5420
    ...as long as you're not using Seam, as Seam variable resolving appears to be broken using the 6-2 nightly.

  • Error  while parsing JSF jspx page when including javascript  loops

    Hi All,
    I have a jspx document which contains jsf tags including trinidad tags. I have added a javascript function in the page, which contains a for loop statement, however when I run the page I get an error
    com.sun.facelets.FaceletException: Error Parsing /xAdvisorWeb/bundles/receivetask/manageinbox.jspx: Error Traced[line: 48] The content of elements must consist of well-formed character data or markup.
    at com.sun.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:234)
    at com.sun.facelets.compiler.Compiler.compile(Compiler.java:104)
    at com.sun.facelets.impl.DefaultFaceletFactory.createFacelet(DefaultFaceletFactory.java:192)
    at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:141)
    at com.sun.facelets.impl.DefaultFaceletFactory.getFacelet(DefaultFaceletFactory.java:93)
    at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:503)
    at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:553)
    at org.apache.myfaces.trinidadinternal.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:178)
    at org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:384)
    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:138)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:995)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:930)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:145)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._invokeDoFilter(TrinidadFilterImpl.java:326)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:290)
    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:213)
    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:90)
    at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:190)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:130)
    at com.ibm.ws.webcontainer.filter.WebAppFilterChain._doFilter(WebAppFilterChain.java:87)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:761)
    at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:673)
    at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:498)
    at com.ibm.ws.wswebcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java:464)
    at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:90)
    at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:744)
    Please note that normal javascript code has worked in my jsf page, this problem only occurs only when I add for loop or while loop in the javascript function. Can we not add javascript loops in a jsf page? Is there something else I need to include?
    This is the relevant code snippet :
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:tr="http://myfaces.apache.org/trinidad"
    xmlns:ch="http://www.chordiant.com/jsf"
    xmlns:chrd="http://chordiant.com/jsf/chrd">
    <f:view locale="#{preferLocale.locale}">
    <f:verbatim escape="true">
    <script>
    function validateInput(){
    for(int i=0;i<3;i++)
    alert('Hi');
    return false;
    </script>
    </f:verbatim>
    <tr:commandLink styleClass="ttmBtnCmdLink" onclick="return validateInput();"
    action="#{manageInbox.executeTaskForAssignedWorkItems}">
    <tr:outputText value="#{msgs.execute_btn}"
    styleClass="ttmBtnOutTxt" />
    </tr:commandLink>
    Any help will be much appreciated.
    Thanks in advance,
    Debajyoti

    M-Y wrote:
    replace "<" with "& l t ;"
    remove spaces in "& l t ;" when u paste it in ur code
    in my previous 2 replies i entered it with out spaces and it was getting converted to "<"The forum engine parses HTML entities. So just replace the & by its HTML entity &amp; and it will work: &lt;.
    But no, this is not going to work. JavaScript doesn't recognize HTML entities as operators.
    Follow the suggestion rlubke gave. Or, even better, put all Javascripts in its own .js file and include this file in the HTML head.

  • Javascript and html menu to be used with ADF/JSF using JDeveloper

    I have a menu for a webpage that was originally built using html and javascript. I need to convert it to be used with JSF and ADF. In the html, the menu items used an unordered list inside of a div tag.
    It looks something like this:
    <!--<div id="shademenu" class="shadetabs">
    <ul>
    <li>Item1</li>
    <li>Item2</li>
    <li>Item3</li>
    <li>Item4</li>
    <li>Item5</li>
    <li>Item 6</li>
    </ul>
    </div> -->
    AND
    the submenu(s) have links that look something like:
    <!--<div id="dropmenu0" class="dropmenudiv">
    Data
    Data
    Data
    </div>-->
    It is unclear to me how to work with my javascript menu to get the same look and feel with JSF or ADF as I did with html. Any insights would be great. Thanks.
    Daniel
    Message was edited by:
    dannyc

    Hello,
    If you do not find any existing JSF component (in ADF Faces/Trinidad, or any other JSF library) you can for sure extend/create your own component with specific renderer that will be the HTML/Javscript that you want.
    So here some interesting pointers about the subject:
    - Buildin Custom JSF component (Chris Schalk)
    - Build Custom JSF Components) (Jonas Jacobi
    - Extending Default Render (and lot of other JavaEE blueprints)
    These links will give you a starting point.
    Regards
    Tugdual Grall

Maybe you are looking for

  • Printing to USB printer connected to old iMac over Network

    I have old Rev B iMac running OS 9 upstairs in the office, this has a USB printer connected to it. Downstairs I have a Mac Mini running OS 10.3.9 Both these machines are networked together via a router. This all seems to work fine, I can see the driv

  • Internal Error: 8004, 7074840, 7076383, 6297905

    Has anyone encountered this error, and do you have a fix or workaround? It's not in the knowledgebase. Symptoms are: FM 8.0 p277, creating PDF using Distill Professional 8.1.2; FM crashes when you try to build a PDF out of a book in one file. I have

  • Quicktime Corruption

    I recently downloaded ITunes and have the icon sitting on my desktop. I have tried to install it several times, but keep receiving the following error: "the cabinet file 'Quicktime.cab' required for this installation is corrupt and cannot be used. Th

  • Print and Page Setup Error

    I just installed CR 2008 and am getting an 'out of memory' error when I hit 'page setup'. After clicking 'okay' on the error, it opens the page setup screen, but attempting to change anything brings up an 'an invalid argument was encountered' error.

  • Time on SUNMC agents complicated!!! and interesting

    Hi, Some of our machines (SUNMC agents) are on a different timezone. Whenever I create graphs the time on the red spots is I dont know what. Any ides n how to change the time of the graphs according to what the time is on the agent. For example = the