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 ?

Similar Messages

  • JSF id generation and javascript

    Hi!
    I am trying to do smethin in my CRUD application and jsf's way of generating ids is making me problem. One part of my jsf page is something like this and it is in dataTable component. When user is "mouseovering" outputText or image next to it I want image to change.
    <h:column>
              <f:facet name="header">
              </f:facet>
              <h:outputText value="#{row.idSubject.name}" onmouseover="changeImage('main:table:3:outer1', '/university/images/rootgen/outer_dark.png');" onmouseout="changeImage('main:table:3:outer1', '/university/images/rootgen/outer.png');"/>
              <h:commandLink action="#{subjectBean.detail}" actionListener="#{subjectBean.idListener}">
                <h:graphicImage url="/images/rootgen/outer.png" id="outer1" onmouseover="changeImage('main:table:3:outer1', '/university/images/rootgen/outer_dark.png');" onmouseout="changeImage('main:table:3:outer1', '/university/images/rootgen/outer.png');"/>
                <f:attribute name="idSubject" value="#{row.idSubject.idSubject}"/>
              </h:commandLink>
            </h:column>I wanted to do it with javascript that looks like this:
    function changeImage(img_id, img_src) {
      document.getElementById(img_id).src = img_src;
    }the thing is that id for each image is something like main:table:{0, 1, 2, ...}:outer1 and I don't know how to generate calling of javascript function different in each row.
    Any ideas?
    Thanks ahead.

    Use the JavaScript this keyword to pass a reference to the DOM element.

  • Oracle Openscript and javascript functions

    I'm using Openscript on a form page that is using a clickable div "save" button. When the button is clicked manually a javascript event is executed to save the changes on the page. When I play back the script, the script clicks on the button and gets redirected to the next page but does not save the changes I made on the text boxes. I'm guessing it doesnt run the ng-click updateUser() function when doing a playback. How can I get openscript to click on the save button and run the javascript function?
    Openscript code:
    web.button( "/web:window[@index='0' or @title=Payment Processor']/web:document[@index='0']/web:form[@name='form' or @index='0']/web:button[@index='1']") .click();
    This is what the div save button code looks like:
    <div class="row"> <div class="col-xs-12"> <button class="btn btn-primary" ng-click="updateUser()"> <i class="fa fa-asterisk"></i> Save </button>  </div> </div>

    Hi,
    You mentioned click action on div element, but your code is click action on button. get Xpath of div element and perform respective action on the same.

  • 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!

  • Repeated area and javascript function

    Hello every body,
    I have a problem and I can't find the solution, but I am sure
    it is solvable !
    my page is a PHP page, I work with Dreamweavere 8
    I have a catalog list which presents global product reference
    based on article designation
    for instance : poppy flower
    when I click on the image I arrive on a new page with
    detailed information, and the different references available (in
    fact I can have 1, 2 or 3 articles references depending on the
    different available sizes).
    I have a form named "ChoixArticle", containing a table with
    the following info coming from a database MySql
    article reference
    article height
    article width
    article color = drop-down list
    article price
    quantity : text area to fullfill
    total price for the article
    I insert a javascript function which works correctly when I
    have only ONE product as result of my query, BUT when I have more
    than one result, it doesn't work anymore
    I insert the code of my page for more brightness.
    hope my explanation is clear enough
    Thank for your welcome help !
    Françoise from Paris
    ========================
    there below my code
    ========================

    > In this case he is not using "id", but "name". When the
    js parser sees
    > form controls with the same name it creates a
    collection.
    >
    > document.forms['ChoixArticle'].elements['res']
    >
    > The first text box is referenced as:
    > document.forms['ChoixArticle'].elements['res'][0]
    > and so on.
    Ahhh I did not pick up on that. Thanks for pointing it out.
    E. Michael Brandt
    www.divaHTML.com
    divaPOP : standards-compliant popup windows
    divaGPS : you-are-here menu highlighting
    divaFAQ : FAQ pages with pizazz
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • JSF form rendering and javascript

    Hi,
    Is there any possibility to execute javascript code each time before the form is rendered? As I see it has nothing like onrender attribute. Where should I put my javascript method call?

    The problem is that this form is situated inside Richfaces tabpanel and it rerenders after some event happens. So, it's not possible to use onload. And I want to show a simple dialog before it's rerendered.

  • Call javascript function using parameters cause a immediate execute at load

    Hello.
    I recognized a strange behavior if I try to use parameters to javascript in af:clientListener method property.
    Using syntax <af:commandButton text="Init" id="cb1"
       partialSubmit="true">
       <af:clientListener method="OnInitControl1" type="click"/>
    </af:commandButton> and javascript function OnInitControl1() {
      alert('OnInitControl1 called');
    } the method OnInitControl1 is called first with the click of the button.
    But with the syntax <af:commandButton text="Init" id="cb1"
       partialSubmit="true">
       <af:clientListener method="InitCtrl('Control1')" type="click"/>
    </af:commandButton> and javascript function InitCtrl(frameName) {
      alert('InitCtrl(' + frameName + ') called');
    }the function InitCtrl is called immediate at load of the page.
    In both cases the javascript file is inserted in af:document using<af:resource type="javascript" source="/ScriptHelper.js"/>Is my syntax for "method" property of the af:clientListener wrong?
    Paul.

    Hi,
    I am using Oracle JDeveloer version 11.1.1.0.2. I have gone through your discussion. Since i am new to ADF, just wanted to request you to share the code related to <af:resource type="javascript" source="/ScriptHelper.js"/>. Also, the Tag included for the same. In my Environment, if i use <af:resource, it shows, "element af: resource is not expected".
    My requirement is similar to your as you explained in details. I need to push all the client side validation to Javascript file and need to call in the ADF pages wherever it is required (re-usable). Also, is there any specific formate for JS file to be maintained from the point of view of ADF calling the JS file.
    Your help will be greatly appreciated.
    Thanks in Advance,
    --Mahesh                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Jsf and javascript to disable a button

    Hi
    is there a way to get the following code to disable the button called next
    when the button "btn" is clicked i call the javascript function myFunc but it does not disable the button called "Next"
    <html>
         <head>
              <title>Personal Info</title>
         </head>
         <body>
         <script type="text/javascript">
         function myFunc()
              document.personalForm.Next.disabled=true;    
         </script>
              <f:view>
                   <h:form id="personalForm">
                   <h:commandButton id="Next" value="Next" action="doSomething" />
                   <h:commandButton id="btn" value="button" immediate="true" onclick="myFunc()"  />
                   </h:form>
              </f:view>
         </body>
    </html>

    You should write Javascript according to the HTML source, not to the JSF code.
    View the generated HTML source and base your JS on that.

  • JSF and JavaScript

    As far as I can see JSF is just a non-portble more verbose version of HTML which just generates a subset of HTML more slowly and with extensive studying a new HTML-like language.. It seems to add nothing, take away a lot, and double complexity.. But that is not important.. Why would web developers want to load the server with validation code when JavaScript in the Browser can increase performance by a factor of 100.. Shouldn't we be striving to use JavaScript in the Browser to enrich and speed up the user experience instead of cutting that avenue off and reinventing an even more clunky and obscure wheel? Is there anyway to have a "tabbed pane" which doesn't rebuild an entirely new page and send it back to the client? Similarly, do any of the implementations encourage client-side validation of simple form inputs using Javascript. Java seems to be being taken over by people with IQs hovering around 100.. I have never understood where most of the J2EE expeditions do anything for Comp. Sci. except reinvent a slower more obscure less portable version of something already a standard..

    Troa, my website has been moved and I need to work on it to get it working again.. I have the source code but I think that would just be confusing.. Basically, there are buttons which call a Javascript function with onClick().. The function shows a form with stuff like this
    function show(formname)
    formEl[oldform].style.display = "none";
    var form = formnum(formname);
    formEl[form].style.display = "block";
    oldform = form;
    and some other DHTML using the newer browser Javascript to just hide a form of components and display another one.. All the components are downloaded at the start.. The buttons just hide and disply..
    As for 1000s of records in tables, it works beautifully if you zip the data as a javascript array.. When the next button is pressed another Javascript function renders the HTML for a page.. It is less network traffic than one page of a normal table.. I'll get it back up working soon and point you to it and the source code.. I just need to install Sun Web Server on my Website, but it is very small in terms of disk size..
    Maybe you should send me your email so we are not filling the forum with personal communication.. My email is [email protected]

  • How to call javascript function & action method on clicking jsf  button?

    I have one jsf custom button. I am checking client side validations in mail by calling javascript function & also sending mail by calling action method of a bean which will execute at server side for onclick event of that button. Because of this when I click on that button its calling both javascript function and action method. So even though validations failed its sending mail. How can I overcome this problem?? Please help me....

    I am asking regarding commanLinks in jsf. I have the following code block in jsf. Even though mailSentMessage('true'); returns false, its calling action="#{emailObjectAction.sendEmail}" method. thats why I got that doubt. try the following code.
    <h:commandLink id="mailBtn123Send"      onclick="return mailSentMessage('true');" value="send mail"     action="#{emailObjectAction.sendEmail}">          
    </h:commandLink>

  • Jsf and javascript variables

    Hello, I am working on a visual jsf project.Inside my project, in a bean java class I have a string variable.Also, I have a jsp page in my project which has some javascript code inside it.Now, I want a method of the javascript to get the value of the string variable that I have in my bean.How is that possible?
    for example, I have the method
    function showAddress(address){
    and a variable in my bean: String addr;
    So I want when I run my project, the value of "address" in my javascript function to have the value of the string addr,but I haven't figured out how I can do that.

    as balusc said:
    The jsf code is generated on server side, then sent to the client (browser). At this time javascript can't call any jsf related code anymore.
    But what you can do is assign a value to a javascript variable when you are processing the jsf file on the server side. Or you can work with ajax and make requests to the server...
    If you work with an IDE, you will notice it will not allow you to assign a javascript value to a jsf variable, no matter how you write it :) The other way round it works

  • Is it possible to embed JavaScript functions into a Flash file (AS 3.0) and call within flash itself, without using the external .js file

    Scenario:
    I have a text area in flash. The user will copy paste any JavaScript  function in the text area and click execute button. The JavaScript function pasted in the text area should be executed with in the flash itself and the return value will be shown in another text field.

    yes,
    function testF(s:String):XML{
        var js:XML = <script>
        <![CDATA[
        ]]>
        </script>
        js.appendChild(XML(s));
        return js;
    ExternalInterface.call(testF(your_tf.text));

  • How to call javascript function in back bean of jsf

    hi,
    i am trying to call java script function in back bean but not done. Is there any code for call javascript function in bean file.

    Java runs at server side.
    JSF produces HTML output.
    Server sends HTML output to client.
    Java stops running.
    HTML runs at client side.
    JS starts to run in HTML.
    Clear? Java is a server side language. JS is a client side language. To run JS using JSF, simply print it out to the HTML so that it get invoked when the HTML runs.

  • How to get value stored in  javascript function and display in a JSP

    i am doing a questionaire which is for user to input data in every question, After user input the data, a javascript function will be called to do some score calculation. Since each question will carry its final score after the calculation by the javascript function, so i use an array to store those scores and then display those scores in the same page.
    However, i have to make a confirmation page to display both data and calculated score in another jsp, i only know how to display the data as it is a textfield that i can get the value by "request.getParameter("textfield1"); but i dun know how to get those scores as they are stored in an array in the javascript function, what way i can do??

    thank you for all your help!
    I have chosen to set the score value to the hidden field when every time run the function
    <script language="javascript">
    function cal(index){
    var thisForm = document.MC;
    thisForm.score1.value=score[index];//set value to the hidden field     
    </script>
    <input type="hidden" name="score1" value="">
    <input type="hidden" name="score2" value="">
    <input type="hidden" name="score3" value="">
    The function will calculate only one score when every time being called. So that i can only assign one score to one hidden value at a time.
    e.g, assign score[1] to thisForm.score1.value
    assign score[2] to thisForm.score2.value
    assign score[3] to thisForm.score3.value
    how can i do this??

  • Calling a javascript function from java code and getting tha value in Java

    Hi,
    I would like to call a Java script function confirmRemove() from Java code upon meeting a condition..
    for example the code snippet is:
    if(true){
    // I want to call js confirmRemove() over here. And get the value of variable "answer" in this if block.
    <html>
    <head>
    <script type="text/javascript">
    function confirmRemove() {
         var answer = confirm("Are you sure you want to Delete?")
    </script>
    </head>
    <body>
    <form>...

    Hi,
    Back in 2003 I have used an Applet which contain java code and this java code was calling the java scripts ( different methods, DHTML etc..)
    There was a component developed by NetScape called JSObject I am not sure it there is other third party component other then the JSObject
    look at this article which shows how (based on JSObject)
    [http://java.sun.com/products/plugin/1.3/docs/jsobject.html|http://java.sun.com/products/plugin/1.3/docs/jsobject.html]
    Regards,
    Alan Meio
    London,UK

Maybe you are looking for

  • RSS Feeds that worked prior to SP2, now do not work

    I am working with SharePoint 2010 Enterprise edition.  We have several wiki pages with RSS feeds that have been working well for a while.  Once we added the SP2 patch, the RSS feeds no longer work unless the page is checked out.  Once checked out, yo

  •  • Photoshop "action" doesn't work well for big file?

    Hello - I made a Photoshop® script (action) which works perfectly- (Open .PDF files in Photoshop®, to after save them as .JPG files into another folder) The problem comes when I launch a batch process. It takes a while to the computer to open the lar

  • Fiscal Year Week wise

    Hi SAP Guru, My client is UK base want fiscal year week wise as per below:- Fiscal year Oct to Sept. Month    Day    Period           Year Shift 10          28        1                 +1 11          28        2                 +1 12          35     

  • Info on 'scrap' order types

    I found many records with the following order types for which I was not able to find an explanation: 1. Purchase order scrap 2. Purchase requisition scrap 3. Planner order scrap Can someone please explain the source and reason to have these order typ

  • How to generate bad records for varchar2 type

    Hi Iam using sqlldr to load records from a flat file to a table. Table columns contains varchar2 datatype Data is loaded by fixedlength position. There is no not null restriction on the fields. I want to have a bad file generated. Can anyone let me k