Triggering a reRender of a JSF component from a Javascript function

Hi
I am using a javascript calendar component(JQuery +JCal) to allow the user to select a date for which they want to see events displayed for. When the user selects the date I was planning on outputting the events in a rich:dataTable or something similar.
Is there anyway that I can trigger a reRender of the dataTable from the javascript, i.e. when someone selects a particular date I would like to trigger a reRender of the rich:dataTable.
I know I can do it easily from another JSF component, e.g. if I had a commandLink I could set the reRender property to be the id of the dataTable. But I am wondering can I trigger the reRender of the dataTable from a Javascript function, i.e. can I submit an AJAX request
Thanks

If you are using the the Richfaces components then you should look at the a4j:jsFunction component, which is provided by Richfaces.
Follow the following format using the a4j:jsFunction:
<a4j:jsFunction name="functionName" reRender="targetCompoentId"/>So in the component that the event should be triggered...like the 'onclick' or 'onmouseover' or whatever the legal event is use the following format:
onclick="functionName();"Richfaces renders the a4j:jsFunction as a javascript function. The a4j:jsFunction name attibute becomes the name of the javascript function; You just have to remember to add the "()" parenthesis to the end of the function name.
You could technically call the function also inside a javascript that has page access to the javascript generated from the a4j:jsFunction component.
Hope this helps!

Similar Messages

  • How can I call a servlet method from a javascript function

    I want to call l a servlet method from a javascript function.
    Does any one have an example of code.
    Thinks in advance

    Actually, as long as the servlet returns valid javascript, you can indeed "call it" from the client. It will initiate a request and return the result to the browser.
    This example uses Perl, but it could be easily modified to go to a servlet instead.
    Note that it is only supported in DOM browsers (IE6+/NN6+/etc)
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
    <html>
    <head>
    <title> Test server-side JS </title>
    </head>
    <body>
    <script type="text/javascript">
    function checkIt(variable, value)
    var newScript = "cgi-bin/validateJS.cgi?"+variable+"="+value;
    var body = document.getElementsByTagName('body').item(0)
    var scriptTag = document.getElementById('loadScript');
    if(scriptTag) body.removeChild(scriptTag);
    script = document.createElement('script');
    script.src = newScript;
         script.type = 'text/javascript';
         script.id = 'loadScript';
         body.appendChild(script)
    </script>
    <p>Test.</p>
    <form id="f1" action="">
    <input type="text" name="t1" id="t1" onChange="checkIt(this.name, this.value)">
    </body>
    </html>
    validateJS.cgi
    #!/opt/x11r6/bin/perl
    use CGI qw(:all);
    my @valArray = split(/=/,$ENV{QUERY_STRING});
    print "Content-type: text/javascript\n\n";
    # myPass is the password
    $myPass = "foobar";
    if ("$valArray[1]" eq "$myPass")
    print "alert(\"Success!!\")";
    else
    print "alert(\"Failure!!\")";

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

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

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

  • Error referencing a Struts-Form element from a JavaScript function.

    As shown below, when referencing the form element named 'custRegion', from the JavaScript function, I get an error msg - document.forms[0].custRegion has no properties.
    It appears that this form-element, which also is present in the logic tag is not visible - is it because I'm referencing it incorrectly...
    <SCRIPT> function setRegion() { var theRegion= 'Western'
    document.forms[0].custRegion.value=theRegion; } </SCRIPT>
    <logic:iterate id="customer" name="customerForm" property="customers" >
    <html:text name="customer" property="custRegion"/>
    <html:select name="customer" property="custState" size="1" onchange="setRegion()">
    <html:option value="1"> California </html:option>
    <html:option value="2"> Arizona </html:option>
    </html:select>
    </logic:iterate>

    Here's a quick example of what may help you. It simply disables the select box and slides in a new text box. Nevertheless, it shows you that you accessed a struts property by name.
    struts code:
    <html:select property="customerRegion">
            <html:option value="-1">Unknown</html:option>
            <html:option value="0">Western</html:option>
    </html:select>
    //quick & dirty textbox for testing.  you'll probably want <html:text ... here instead.
    <input type="checkbox"
           onclick="disableSelectAddTxt(document.YOUR_FORM['customerRegion'], this.checked)" />
    Check box to replace select pull-down  
          <div id="setTBox"></div>javascript:
    function disableSelectAddTxt(selectBoxName, disableIt)
        var setTBoxName = selectBoxName;
        //alert('You passed me ' +setTBoxName+ ' and' +disableIt);
        selectBoxName.disabled = disableIt;
        var setTBox = document.getElementById("setTBox");
        if (disableSelect == true) {
            setTBox.innerHTML = "<input type=\"text\" name="+setTBoxName+ "size=\"10\">";
        if (disableSelect == false) {
            setTBox.innerHTML = "";
      hope this helps.

  • Control JSF Component navigation thru Javascript

    <a4j:region>
                                                 <h:inputText id="bc1"                     value="#{addHardware.barCode1}"           valueChangeListener="#{addHardware.processValueChange}"          style="border-right-color: BLUE; border-bottom-color: BLUE; border-top-width: medium; border-top-color: BLUE; border-right-width: medium; border-left-width: medium; border-left-color: BLUE; border-bottom-width: medium">
                                                 <a4j:support event="onfocus"           reRender="form1"/>
                                                 <a4j:support event="onblur"               reRender="bc1, displayMessageLabel, errmsgheader, addnotesbtn, submit"/>
                                                 </h:inputText>
                                                 </a4j:region>
    Question: How can I pass the values to the Javascript function if my backing bean returns two values such as component id (in the above example "bc1") and validational error msg so that I can keep the focus on the same component (thru Javascript) when validational error message exists.
    If my question is not clear,....please let me know ...Thx for your help

    Maybe I just haven't looked far enough but it seems
    that using client-side Javascript is not intended to
    be used/asociated with JSF.I'm not sure how much is mentioned about this in the current draft (if at all), but the intention is that client-side code can be generated (by the component or by a renderer) to perform things like validation of the client when possible (in addition to the server validation, just to speed things up). This is an area that 's even more "work in progress" than other parts.

  • JRE7 Update 13 blocking java applet from calling javascript functions

    Hi there,
    I'm having a problem where I have a javascript web app that launches an applet that communicates back to the javascript via invoking javascipt methods. It uses the method call from netscape.javascript.JSObject to achieve this. Pre JRE7 Update 13, everything worked fine, but now whenever I try to call a javascript method, it throws a netscape.javascript.JSException: No such method "..." on JavaScript object . This happens only on Firefox and Chrome; however it still works fine in Internet Explorer. Are there some new security settings in JRE7u13 that need to be addressed in order to allow javascript method calling, or is it a Java/Firefox/Chrome bug?
    Thank you for any help!

    I've filed a bug https://bugzilla.mozilla.org/show_bug.cgi?id=839967 but I'm having problems reproducing it in a testcase...everything works. Quite baffling, our application that had worked and still works with other browsers and with an old version of firefox (12) stopped working with the Java 7 update 13.

  • JSF 2.0 and javascript function

    I am using jsf 2.0, NetBeans 7.2 and WLS 12c.
    In JSF page I am callling a js script function and on submit it should invoking the backing beans method.
    <h:commandButton id="btnUpload" value="Login" onclick="showProgress(); return false;" action="#{login.dologin}" />
    Because return false is used it invokes the js function but does not do the invoke the method specified in the action attribute. instead i get new window which is a duplicate of the current.
    If js method is not there it invokes the action method.

    If js method is not there it invokes the action method.So try with the JS function there, but without the return false ?

  • Import HTC in JSF and invoke the javascript function in it

    Hello,
    I am trying to import HTC file in JSF file using sysntax below.
    <?import namespace="testtest" implementation="/Advisor/iAdvisorWeb/appcomponents/tree/tree.htc" ?>
    When I want to use the function within this HTC file in JSF file, then it doesn't find that function and gives javascript error.
    Thanks for your time and help.
    Hiren

    This can happen if Firefox is in private browsing mode. for details of how to turn off private browsing mode see the [[private browsing]] article.

  • Access client DOM id of current JSF component via an EL statement

    Is it possible to access the client-side DOM id of a JSF component from within an EL statement?
    For example:
    <a4j:commandLink id="marketNameLink" action="#{testAction.myFunction( 'some how get client DOM id' )} />
    I could use rich:clientId('marketNameLink'), except I think that this is a bit wasteful in processing time to search the complete DOM tree to access the id of the current component.
    Any ideas?
    Philip

    EL are evaluted at server side and DOM id are generated for the client side
    I advice you to read this article :
    [http://balusc.blogspot.com/2009/05/javajspjsf-and-javascript.html|http://balusc.blogspot.com/2009/05/javajspjsf-and-javascript.html]
    and also this on :
    [http://weblogs.java.net/blog/2009/07/22/say-sayonara-spal|http://weblogs.java.net/blog/2009/07/22/say-sayonara-spal]

  • Calling Javascript function from PL/SQL Page Process

    Hi All,
    So far I have seen many threads that answered the question: Calling a PL/SQL from a Javascript function. I would like to know if it's posiible to do the reverse process as follows:
    DECLARE
       v_name APPLICANTS.NAME%Type;
       v_surname APPLICANTS.SURNAME%Type;
       v_idNumber APPLICANTS.ID_NUMBER%Type;
    BEGIN
       select name, surname
       into v_name, v_surname
       from APPLICANTS
       where id_number = :P2_ID_NUMBER;
       //Javascript function call Syntax is what i'd like find out
       onchange="javascript:show_Name(v_name,v_surname);";
    EXCEPTION
       WHEN OTHERS
       THEN
       onchange="javascript:show_Exception(v_name,v_surname);";
    END;& Javascript function to shiow applicant's details is:
    function show_Name(item1,item2){
       alert('Applicant's Name is: '  + item1 + ' & Surname is: ' + item2);
    }THANK YOU!
    Regards
    Kamo

    Hi Dinesh, Thanks for the response!
    I've also tried doing the following without success:
    DECLARE
       v_name APPLICANTS.NAME%Type;
       v_surname APPLICANTS.SURNAME%Type;
       v_idNumber APPLICANTS.ID_NUMBER%Type;
    BEGIN
       select name, surname
       into v_name, v_surname
       from APPLICANTS
       where id_number = :P2_ID_NUMBER;
       htp.p('<script type="text/javascript">');
       htp.p('
                alert('Applicant's Name is: '  + v_name + ' & Surname is: ' + v_surname);
       htp.p('</script>');
    EXCEPTION
       WHEN OTHERS
       THEN
       htp.p('<script type="text/javascript">');
       htp.p('
             alert('Exception.');
       htp.p('</script>');;
    END;Do you know why this is not working?
    Regards
    Kamo

  • Can we execute a Powershell script from the Javascript?

    Hi,
    I have a certain requirement to add a Custom ribbon button in document library and there was a powershell script to be run for the selected item in the library.
    I have struck with executing a Powershell script from the javascript function.
    Can anyone please suggest me if this was achievable
    Thanks, Swaroop Vuppala

    Hi Swaroop,
    To execute server side code in a custom ribbon button script, using application page is a common way to do this, besides, you can also use a page dialog, which is similar with application page but display as model dialog, another way is javascript
    _dopostback and delegate control, the following article contains detailed information about this, please refer to it for more information:
    Invoke server side code on SharePoint ribbon click:
    http://sharepointnadeem.blogspot.in/2012/07/invoke-server-side-code-on-sharepoint.html
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Calling a method in the Custom ADF component from JSF page

    HI.
    I have created some custom compoents by extending the core ADF Components. Like i have a ComboBoxDefault component with it's ComboBoxDefaultTag.java and Controls.tld file.
    Now my requirement is i want to bind my label to this component from the JSF page. like
    <fwcontrols:label binding="#{listComponents.comboBoxDefaultLabel}" id="label1"/>
    <fwcontrols:comboBoxDefault binding="#{listComponents.cmbLocales}"
    value="en_GB" id="comboBoxDefault" autoSubmit="true" label="label1">
    <f:selectItems value="#{listComponents.locales}"/>
    </fwcontrols:comboBoxDefault>
    In my JSF page the label will have an id, and that id will be specified in the label tag of the component.
    In Tag.java file i have overrided the setProperty(FacesBean facesBean). In this method i have bind all my properties. In core JSF the setProperty method is provided with the UIComponent parameter, so i can call my method in component also. Which is not in case of ADF Faces.
    My main point is how i can call my method setLabel() which is in ComboBoxDefault.java so that i can set the label.
    Thanks in Advance.

    Thanks for all your replies. I want this kind of a functionality because Im trying to invove a DC (Child DC) from a Parent DC such that the Child DC's view is displayed onto the view container of the Parent DC. I have embedded using 'interface view of a component instance' in the Parent Window and am able to create the component and set usage though the onPlugDefault of the Child View.
    But I observe that when i make a call from the parent, the flow is like this:
    1. The wdDoInit of the Child Component Controller gets triggered first.
    2. Then the wdDoInit of the Child's <b>VIEW</b> gets triggered
    3. and <b>THEN</b> the onPlugDefault of the Child Component Interface View
    What I had actually wanted was to Fire onPlugDefault where Im calling a method LoadData(), after which the Child DC's view must be triggered so it can display the fetched data.
    What is actually happening is the view gets displayed, but no data is displayed in the view.
    Right now I have just given a work around where Im triggering <b>LoadData()</b> of the <b>COmponent COntroller</b> from the <b>wdDoInit</b> of the <b>VIEW</b>.
    Is there a better way to do this? I find it strange that I have to load the Data from the view.
    Thanks
    Jack

  • How can I include a javaScript files from within jsf component

    Is there any way using which I can include javascript files from my jsf component. Because otherwise I have to write all the javascript commands using writer.write which is very tedious rather than this I just want to include the javascript file which contains all the functions required. Also I want that this file should be included only once irrespective of the number of components included.
    Thanx in advance

    This doesn't depend on JSF. You need to include a script tag, like:
    <script src="/path/script.js"
    language="JavaScript" type="text/javascript"></script>
    If you want to include this only once, make a file included into every page, into which you can put other resources to be included along with this script.
    HTH,
    rs.

  • How to load a class dynamically (via reflection) in a jsf-component

    Hi all,
    I am writing my own jsf component and I would like to do it generically. Therefore I have an attribute, where the developer can pass a fully qualified classname, which I want to use to instantiate. But I have a Problem with the classloaders, everytime I get a ClassNotFound-Exception during debugging.
    Does anybody know how it is possible, to to get the most parent classloader?
    Currently I am even not able to load a class, which is in the same package like all other compontent-classes.
    Thank you very much in advance
    Thomas

    Within web applications, I believe it is recommended to use Thread.getContextClassLoader(). Keep in mind that web applications require different classloader semantics than regular Java applications. The class loader which gets resources from the WAR is favored over others, even when this violates the normal class loading conventions.

  • How to add properties to a custom JSF component?

    Hello, everybody!
    I've just developed my first custom JSF component. It's a data pager and it is working pretty well. But now I want to be able to use some of it attributes in my backing beans at runtime. I mean, I want to bind it to component in the JSF page. It already has a binding attribute in the tld file, but I want to be able to accesss two values that the renderer of my custom component calculate inside it, which would relieve me from calculating these values manually in the backing beans. So, I would like to know how to make these values external to the component.
    By now this is my custom pager class:
    import javax.faces.component.UICommand;
    public class UIPaginadorDados extends UICommand
    }You can see that it has no logic because all the logic is in the renderer class:
    import javax.faces.render.Renderer;
    public class PaginadorDadosRenderer extends Renderer
        // logic here
    }As I said I want to be able to do the following in my backing beans:
    private UIPaginadorDados pager = new UIPaginadorDados();
    // and later...
    pager.getCurrentPage();
    pager.getPageCount();In the JSF page:
    // I already can do this, because I have a binding attribute
    <urca:paginadorDados binding="#{backingBean.pager}" />I suppose that I'll have to create the properties getCurrentPage() and getPageCount() in the component class, UIPaginadorDados, but I don't know how to get the values to the properties from the renderer class. I don't even know if this is how I should do it.
    So I would appreciate a lot your help about this subject.
    Thank you.
    Marcos

    Marcos_AntonioPS wrote:
    RaymondDeCampo wrote:
    I neglected to mention: do not forget to implement the methods in StateHolder to preserve the properties you added to your component.Hello, Raymond. Could you elaborate a little more on that? If you could give a short example, it would be helpful.
    MarcosNo problem. I have already found out how.
    Thank you very much, Raymond.
    Marcos

Maybe you are looking for

  • Data not loading from R/3 to BW

    Hello I am a new user in SAP BW, but i am quite familiar with it now. I am trying to load or extract data from the SAP r/3 system to the BW system. When i check the value of my extractor in rsa3 , i can see the records. But when i try to load into th

  • ITunes no longer plays music

    All of the sudden my itunes stopped playing music. When I try to play a song, the song info appears in the menu area but the diamond does not move along the song bar and the little speaker icon by the song title in the playlist does not have lines co

  • Yoga 2 Pro Cracked Screen and more....

    I ordered a Yoga 2 Pro direct from LENOVO very late December - delivered around January 1st. I didn't have the time to unpack and examine for about a week. I unpacked and first turn on the computer around January 7...and over the next few days spent

  • OEL6 Validated RPM

    Hello guys! I downloaded the OEL6, lately and I can't find Oracle Validated package at path that provided in Oracle Installation documentation(valid only for OEL5). Maybe It's not included? But according to the documentation this package must be incl

  • Reinstall OSX on New Mac Pro

    Hi, I have a new Mac Pro and I want to rebuild it. I have a bootable USB Key that I made with the 10.9 installer from the App Store. This installer works as a bootable image for the old Mac Pro's and for MacBook pro's, but I can't get a new Mac Pro t