H:commandButton Javascript

I have a JSF button that when i click this invokes a javascript
<h:commandButton value="testing" action="#{index.indexSearchAction}" onclick="invokeJavascript">
</h:commandButton>Is there a way to ensure that the Action bean is invoked before the javascript

lakabo wrote:
I have a JSF button that when i click this invokes a javascript
<h:commandButton value="testing" action="#{index.indexSearchAction}" onclick="invokeJavascript">
</h:commandButton>Is there a way to ensure that the Action bean is invoked before the javascriptThat is not the purpose of the onclick event. Place your script in the onload handler of the response. You may want to investigate AJAX techniques as well.

Similar Messages

  • Dynamic resizing of popups

    Hi All,
    I am using JDev 11.1.2.4.0 and  bounded taskflows.
    In my fragment I have a popup with panel Window. I want to set the content width & height of this as per the browser
    I followed the steps as per this http://www.ateam-oracle.com/dynamic-resizing-for-popup-dialogs/
    My popup code is as below
                                       <af:popup id="pdfPopup" autoCancel="disabled" partialTriggers="cb1"
                                                  popupCanceledListener="#{rLBean.closeDetachPopup}"
                                                  contentDelivery="lazyUncached">
                                            <af:panelWindow id="pdfWindow" title="Label Design" modal="true"
                                                            stretchChildren="first">
                                                <af:panelStretchLayout id="psl7" startWidth="0px" endWidth="0px"
                                                                       topHeight="0px" bottomHeight="0px">
                                                    <f:facet name="bottom"/>
                                                    <f:facet name="center">
                                                        <af:inlineFrame id="if2"
                                                                        source="/pdfservlet?#{bindings.LId.inputValue}*#{bindings.LVn.inputValue}"/>
                                                    </f:facet>
                                                    <f:facet name="start"/>
                                                    <f:facet name="end"/>
                                                    <f:facet name="top"/>
                                                </af:panelStretchLayout>
                                            </af:panelWindow>
                                        </af:popup>
    This popup is invoked as below
         <af:commandButton text="Maximize" id="cb1" partialSubmit="true"
                                                                          clientComponent="true"
                                                                          icon="/images/maximize_detach.png"
                                                                          shortDesc="Maximize" blocking="true">
                                                            <af:clientListener type="action"
                                                                               method="openPopup('pt1:pdfPopup','pt1:pdfWindow')"/>
                                                        </af:commandButton>
    Javascript method is as below
    function openPopup(popupId, panelWindowId) {
        return function (event) {
            try {
                var agent = AdfAgent.AGENT;
                var windowWidth = agent.getWindowWidth();
                var windowHeight = agent.getWindowHeight();
                //alert('maximize.............');
                var region = AdfPage.PAGE.findComponentByAbsoluteId('r1');
                //alert(region +' ------------ '+popupId+' --------------- '+panelWindowId);
                var popup = region.findComponent(popupId);
                //alert(popup);
                var panelWindow = popup.findComponent(panelWindowId);
                alert(panelWindow);
                panelWindow.setContentWidth(Math.max(100, windowWidth - 100));
                panelWindow.setContentHeight(Math.max(100, windowHeight - 100));
                if (popup != null)
                    popup.show();
                else
                    popup.hide();
            catch (err) {
                alert(err);
    When alert is there, I am getting the ID of panel window and everything works fine.
    But if I comment the alerts, its returning null. I dont know whats going wrong.
    Kindly Help

    Issue is, with the above code, I am not able to get the panel window ID.
    As you'll can see in the javascript code, I have commented the alerts. Magically, if i uncomment one of the alerts, its able to find the ID.
    Yes..!! I have tried this code by setting the clientComponent=true for the pop-up as well as panelWindow. But it didn't help.....
    Kind Regards

  • Making a commandButton's action dependant on a javascript function's result

    Hi guys,
    I have a command button "Login". I have a managed bean "userLoginInfoBean" with session scope whose "loginToSystem" method I want to call when user clicks on Login button.
    <h:commandButton id="loginButton" type="submit" value="Login" style="font-family: Verdana; font-size: 8pt" action="#{userLoginInfoBean.loginToSystem}">So far so good. Its working perfect.
    Now before calling the action, I want to call a javascript function isGoAhead(). This javascript function will return true or false. Only when it returns true then I want to call the action.
    How can I do it in JSF?
    Thanks

    I know using onclick attribute I can call my javascript function "isGoAhead()"
    <h:commandButton id="loginButton" type="submit" value="Login" style="font-family: Verdana; font-size: 8pt" onclick="isGoAhead();" action="#{userLoginInfoBean.loginToSystem}">But the question is how to make sure that the commandButton's action only gets called if the return value from "isGoAhead()" is true?
    Thanks

  • Click af:commandButton from javascript

    Hey
    I'm having the same issue as you. I want my session to be destroyed when a users closes the window.
    As onUnload triggers every time you navigate away from the page I can't use it. Instead I'm using the following Js code:
    <script type="text/javascript">
    window.onbeforeunload=function(){
    if (window.event.clientY &lt; 0 &amp;&amp; (window.event.clientX &gt; (document.documentElement.clientWidth - 5) || window.event.clientX &lt; 15) ) {                       
    document.getElementById('hiddenButton').click();
    </script>
    my af:commandButton has the following structure :
    <af:commandButton text="" id="hiddenButton"
    onclick="if (confirm('#{res['sag.generales.cerrarSesion']}')) {window.document.all['logoutFrame'].src='../servlet/LogoutServlet';window.setTimeout('closeWindow()',100);}"/>
    <af:regionDef var="attrs">
    But is sadly not working. When I close the page nothing executes.
    On the other hand if I use a regular button instead of an commandButton I'm able to click it via javascript
    <input type="button" name="theSubmitButton" id="hiddenButton" value="Button" onclick="alert('The button was clicked.');"/>
    i mean, in this case when i close the window i get the message "The button was clicked". But if I use the same code I have on the af:commandButton onclick for closing my session nothing happens.
    I'm super new to adf and java so maybe I'm missing something obvious.
    Thanks a lot for your hepl. I mean it :)
    Edited by: loskiorama on Jun 20, 2011 8:54 AM

    Hey!
    Thanks for your help guys!
    Frank:
    I tried as you mentioned
    window.onbeforeunload=function(){
    if (window.event.clientY &lt; 0 &amp;&amp; (window.event.clientX &gt; (document.documentElement.clientWidth - 5) || window.event.clientX &lt; 15) ) {                       
    var button = AdfPage.PAGE.findComponentById('hiddenButton');
    AdfActionEvent.queue(button,true);
    <af:commandButton text="" id="hiddenButton"
    onclick="if (confirm('#{res['sag.generales.cerrarSesion']}')) {window.document.all['logoutFrame'].src='../servlet/LogoutServlet';window.setTimeout('closeWindow()',100);}"/>
    but when i close the window. the commandButton onckick in not executing. Maybe is because as I'm closing the window, the event doesn't get queued in time. i don't know
    Vinod:
    I'm using a onlcik on my af:CommandButton button
    <af:commandButton text="" id="hiddenButton"
    onclick="if (confirm('#{res['sag.generales.cerrarSesion']}')) {window.document.all['logoutFrame'].src='../servlet/LogoutServlet';window.setTimeout('closeWindow()',100);}"/>
    When I click the button it works fine. but what I want to do is click this same button from javascript
    Thanks so mucho for your help guys. Hope you can keep helping me find a solution

  • Javascript back on JSF commandButton

    I am having a problem trying to add an onclick event to my JSF commandButton. All I want it to do is perform a simple "history.back();". I can put a simple "alert();" for the onclick event and that works just fine. Also if I use an ADF commandButton instead it works just fine. Any ideas on what the problem could be?

    I think your problem lies elsewhere on the page.
    I had a similar problem and posted on it yesterday. See my post titled:
    Why can't I access my button click method?
    I could get the alert() method to work, but not the button click that followed.
    The problem I had was completely unrelated to the javascript itself.
    It had to do with binding to another component.
    When I removed that binding, everything worked.
    If you can get the alert() message, then you are accessing your onclick method.
    I would suggest creating a new page that just contains the single button and it's onclick method.
    If that works, then you have a problem elsewhere on the page.
    The next thing I would do is to remove any bindings on the other components.
    If that works, then put the bindings back until you find the error.
    The only reason I am focusing on bindings is because that is what caused my problem.
    Hope this helps.

  • [SOLVED] ADF - How to disable/enable CommandButton from JavaScript

    CommandButton is rendered as a image in HTML and image does not have disabled property in JavaScript. Is there some other way to dynamically change render property of ADF/CommandButton without auto submitting?

    - if you don't mind that it doesn't 'look' disabled, you can have an onClick return false
    - you might be able to hide it by putting it in the custom 'div' tag someone recently posted on this forum and then using visibility:hidden from the javascript
    - or you could put it in the div tag, or use a seperate div tag and float that on top, and play around with opacities
    - or you could just grit your teeth and do the partial submit. Hmm, speed vs. maintainability :-p

  • CommandButton and javascript

    I'm getting an error trying to execute a javascript function using the oncick attribute of the commandButton. The Error message says "Object expected". Here are some code snippets.
    <h:commandButton type="button" value="Add Comment"
    onclick="gatherInput();" />
    function gatherInput() {
    alert("Can you see me now?");
    However the following code works...
    <h:commandButton type="button" value="Add Comment"
    onclick="form['facilityAssessment:roofComment'].value = prompt('Describe roof condition.','')" />
    What am I doing wrong?
    Thanks for your input.

    Use the "this" reference: this.disabled='true';
    But you're trying to avoid the double submit? Well, I can tell you that it won't work this way .. When a button is disabled before the action is invoked, then the action simply won't be invoked. Check this article for a solution: http://www.jroller.com/page/mert?entry=jsf_preventing_double_form_submit

  • CommandButton set to only call javascript, not submit the page

    Hello All,
    I have a problem with commandButton. I would like to use commandButton just to call JavaScript. When the user clicks the button, a JS function runs. My problem, is that I don't want to submit the form, right then. I leave the action and actionListener attributes out, but the command button still submits the form. Is there a better way to do this?
    Thanks,
    Grae

    IF you don't want a submit button, then why you use it?
    I mean if you want a button that calls a javaScript code then use:
    <input type="button" value="xxxx" onclick="xxx( )" />However, if you want to use a submit button (commanButton) but you want to contorl the submission based on JavaScript result fucntion then use:
    <h:commandButton onClick="return xxx( ) " ......................... />note the keyword return above, and don't forget to return ture (to submit the page) or false( to ban submission).

  • Javascript h:commandButton issue.

    I am having an issue with the following JSF jsp which basically pops up an alert window to confirm deletion. Now the issue is once in a while the backing bean delete action is not called. This is not occuring all the time. Here is the jsp for the command button
    <h:form>....
         <h:commandButton value="#{msgs['view.add.delete']}"
         action="#{DynamicEditBean.delete}" onclick="return window.confirm('Are you sure you want to delete this content?')"/>
    </h:form>Am I doing something wrong here ? Any suggestions ?
    Forgot to add that I am using the JSF runtime with IBM Rational App Developer 6.0.1.
    Edited by: ckshah on Dec 11, 2007 8:44 AM

    No the CommandButton is part of a h:form (edit form) which has a delete button to delete the current record. The interesting part is that for all other value bindings the input field value attribute is not reset... e.g.
                      HtmlInputText iText = new HtmlInputText();
                      iText.setSize(Integer.parseInt(attrInfo.getMinValue()));
              iText.setMaxlength(attrInfo[i].getMaxValue());
              String bind = "#{DynamicEditBean.datafieldMap['" + fieldName+ "']}";
              iText.setValueBinding("value",app.createValueBinding(bind));
    the html code on refresh of the page is <input id="viewPC_7_0_7K0_:_id0:ID77" type="text" name="viewPC_7_0_7K0_:_id0:ID77" value="gmail" maxlength="200" size="50" />
    Just for the HtmlInputHidden value is reset.. <input id="viewPC_7_0_7K0_:_id0:IDHiddenRow" type="hidden" name="viewPC_7_0_7K0_:_id0:IDHiddenRow" />
    Any ideas..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Adding items to a selectOneListbox from Javascript

    In my JSF page I have...
    <h:form id="alternateDeviceSelectForm">
        <h:selectOneListbox id="selectBox"/>
        <h:commandButton id="okButton" value="#{i18n.ok}" action="#{aBean.anActionMethod}"/>
    </h:form>I also have this Javascript...
    for (var i=0; i < devices.length; i++) {
        var device = devices;
    // a String
    var id = device.getId();
    // another String
    var displayName = device.getDisplayName();
    this.selectBox.options[i] = new Option(displayName,id);
    This creates the listbox and when the Javascript method fires, the appropriate items are listed in as list items.  However, when I hit the OK button, I get a JSF message about a validation error.  I'm not using any custom validation at all.
    Here's the error message I get... "alternateDeviceSelectForm:selectBox: Validation Error: Value is not valid"
    Any ideas on how I can get this working?  (I have to get the listbox item values from Javascript because that is the interface to a browser plugin that is involved in this process.)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    dalearyous wrote:
    the only thing is there is no data to begin with. after you choose the data structure there is a text field to type in something like apple and then you click add. then you can type in something like pear and click add.If you do it right, the part that controls the data structures won't need to directly interact with the part that adds/removes the elements in the data structures -- they'll be independent units. That's what we call "orthogonal", and it helps make programs much easier to develop and maintain. To do that, you have a common set of add/remove operations across all data structures -- just like in the Collections framework, which you should use unless your teacher is telling you that you must make your own. (And even if you do, ask your teacher if you can use the interfaces from the Collections framework, if not the implementations.)
    The example I showed you supports that, in that it doesn't assume that the data structures initially contain any data. (Though it might be better to create empty Collections in your constructor, rather than ever letting existingCollection go null.

  • Problem with Javascript and opening a new page

    Hi,
    I'm developping a website with Java Server Faces.
    I've a problem with JavaScript.
    I have a table, and each row of that table, has a button, to display more information about that specific row. I want to display this information in a new window. For this I want to use JavaScript.
    The new window, of course, needs some information of the other window, to show the right data.
    The first time I click the 'more-information-button', it works perfectly, but from than on, he keeps showing the same information...
    Here is my jsp-page of the first page (the one with the table):
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <f:view>
             <f:loadBundle basename="languages.MessageBundle" var="bundle"/>
            <html>
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>- UCV-Period -</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                        <h:dataTable binding="#{UcvPeriod.dataTable1}" headerClass="list-header" id="dataTable1" rowClasses="list-row-even,list-row-odd" rows="5"
                            style="left: 24px; top: 168px; position: absolute" value="#{UcvPeriod.dataTable1Model}" var="currentRow">
                            <h:column binding="#{UcvPeriod.column1}" id="column1">
                                <h:outputText binding="#{UcvPeriod.outputUcvPeriod}" id="outputUcvPeriod" value="#{currentRow['UCVPERIOD']}"/>
                                <f:facet name="header">
                                    <h:outputText binding="#{UcvPeriod.outputText2}" id="outputText2" value="#{bundle.ucvPeriod_columnHeader_ucvPeriod}"/>
                                </f:facet>
                            </h:column>
                            <h:column binding="#{UcvPeriod.column11}" id="column11">
                                <h:commandButton action="#{UcvPeriod.btnDetails_action}" binding="#{UcvPeriod.btnDetails}" id="btnDetails" value="+" onclick="window.open('Details.jsp')"/>
                                <f:facet name="header">
                                    <h:outputText binding="#{UcvPeriod.outputText21}" id="outputText21" value=""/>
                                </f:facet>
                            </h:column>
                        </h:dataTable>
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>Here is my action, when someone clicks on the 'more-information-button':
    public String bthnDetails_action() {
       Object s = outputUcvPeriod.getValue();
       BigDecimal ucvPeriod = (BigDecimal)outputUcvPeriod.getValue();
       this.getSessionBean().setUcvPeriod(new Integer(ucvPeriod.intValue());
       return "detail_ucvperiod";
    }Here is my constructor of the Detailspage.
        public Details() {
             this.txtUcvPeriod.setValue(this.getSessionBean().getUcvPeriod());
        }Here is the navigation part for this part of my faces-config.xml .
    <navigation-rule>
       <from-view-id>/UcvPeriod.jsp</from-view-id>
       <navigation-case>
           <from-outcome>detail_ucvperiod</from-outcome>
           <to-view-id>/UcvPeriod.jsp</to-view-id>
       </navigation-case>
    </navigation-rule>Thx a lot....
    Anneke

    See the tutorial "Sharing Data Between Two Pages" at http://devservices.sun.com/premium/jscreator/standard/learning/tutorials/data_sharing_twopages.html and the FAQ "How can I pass data between pages without creating SessionBean variables in Creator?" at http://devservices.sun.com/premium/jscreator/standard/reference/faqs/technical/javasource/passing_data.html. Since you can open a new window when your button is clicked, the tutorial and FAQ will explain ways to pass your data to the new window.

  • How to close popup with af:commandButton without submitting values?

    Hi all,
    I'm using JDeveloper 11.1.2.1
    My popup has few af:inputText components with value attribute binded to view scope variables.
    I set those view scope variables in backing bean before showing popup.
    When I change values of input fields and click cancel (af:commandButton, partialSubmit=true, immediate=true), popup is closed.
    Then, when I show popup again, values that I changed are visible although I set new values to view scope variables in backing bean before showing popup again.
    I noticed that when I close popup using close icon in upper right corner of popup everything works fine.
    Also, I tried using dialog cancel button and it also works fine.
    Is there a way for closing popup using af:commandButton but without submitting values?
    In previous releases of JDeveloper (<= 11.1.1.5) I didn't noticed this problem.
    Thanks in advance,
    Aleksandar

    Alexandar wrote:
    Is there a way for closing popup using af:commandButton but without submitting values?If you really want to use your own button without submitting, then some three lines of Javascript will do the trick. See the documentation of af:popup for that. Canceling a popup is a pure client-side operation. No event is sent to the server. No submit. No need to reset anything. That's basically what the built-in cancel button does as well.
    Sascha

  • Value from backing bean in javascript confirm in 10.1.3

    Hallo,
    Please help
    I have 2 problems:
    Page with 1 record, where 8 items are updatable.
    In entity I 've a method where I set a value in bean. (BotId1 is one of these 8 updatebale items)
    What I expect: when I change a value in BotId1 the value of botId in ValiderenBotBean will be also changed
    public void setBotId1(Number value) {
    setAttributeInternal(BOTID1, value);
    EL.set("#{ValiderenBotBean.botId}",BotId.toString());
    My bean (session scope):
    package viewcontroller.pagedefs.produceren.backing;
    import org.apache.commons.logging.Log;
    import org.apache.commons.logging.LogFactory;
    public class ValiderenBotBean
    private static Log log = LogFactory.getLog(ValiderenBotBean.class);
    private String botId;
    public ValiderenBotBean() {
    // accessors
    public void setBotId(String botId) {
    log.debug("setBotId : " + botId);
    this.botId = botId;
    public String getBotId() {
    log.debug("getBotId : " + this.botId);
    return this.botId;
    Op my generaten page I have the button:
    <af:commandButton actionListener="#{bindings.Commit.execute}"
    action="Commit" onclick="if (validateForm('dataForm')){return(confirm(#{ValiderenBotBean.botId} + 'la')}"
    rendered="#{(((jhsUserRoles['JDMR_PRD03']) or (jhsUserRoles['JDMR_PRD03'])) or (jhsUserRoles['JDMR_PRD03'])) or (jhsUserRoles['JDMR_PRD03'])}" textAndAccessKey="#{nls['SAVE_BUTTON_LABEL_KOPPELENPRODUCTIEGEGEVENS']}"
    id="KoppelenProductiegegevensSaveButton">
    <af:resetActionListener/>
    </af:commandButton>
    I get the following error:
    Foutdetails webpagina
    Gebruikersagent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.6; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; InfoPath.1; AskTB5.6)
    Tijdstempel: Thu, 17 Feb 2011 13:54:46 UTC
    Bericht: Syntaxisfout
    Regel: 3744
    Teken: 1
    Code: 0
    URI: http://172.16.6.108:8988/demeter/adf/jsLibs/Common10_1_3_2_0.js
    The code from Common:
    3732 function _callChained(
    3733 a0,
    3734 a1,
    3735 a2
    3736 )
    3737 {
    3738 if(a0&&(a0.length>0))
    3739 {
    3740 if(a2==(void 0))
    3741 {
    3742 a2=a1.window.event;
    3743 }
    3744 var a3=new Function("event",a0);
    3745 a1._tempFunc=a3;
    3746 var a4=a1._tempFunc(a2);
    3747 a1._tempFunc=(void 0);
    3748 return!(a4==false);
    3749 }
    3750 else
    3751 {
    3752 return true;
    3753 }
    3754 }
    Problem nr.1:
    When I call the button I do not see any logging that indicate that the value is set in backing bean
    Workaround: I made item on my page depending on item where I put my code.
    Result: I have to press 2 times on my button to execute the button code. First time to make the validation and the second time the button code itself.
    Not nice. The validation is also slow.
    But ok:
    Problem 2:
    I still get the same error, I see logging of execution of my validation.
    There is also the difference between loggings is 2 cases:
    If I use
    onclick="if (validateForm('dataForm')){return((#{ValiderenBotBean.botId} + 'la')}"
    what I really want instead of
    onclick="if (validateForm('dataForm')){return'la')}"
    I get:
    17-feb 14:28:40 DEBUG (ValiderenBotBean) -getBotId : -1
    17-feb 14:28:40 DEBUG (ValiderenBotBean) -getBotId : -1
    It means that value is obtained correctly.
    But still the same error.
    If I put for test purpose
    the following code into my bean:
    public String getBotId() {
    log.debug("getBotId : " + this.botId);
    botId = "23";
    return this.botId;
    I do not get any error.
    Any ideas?
    Please help

    Thanks, Amit,
    I will try it tomorrow.
    Some remarkes:
    1. I need javascript for confirmation
    2. I really do not PPR. It takes so long. The user use the scanner to put the value into input items in order speed up the process. And now PPR...
    3. My transient attribute will depend on 8 items. Even more waiting process.
    What I really want is to execute my db function only 1 time "onclick" or "oncommit" and according to outcome of db-function ask user for confirmation of commit.
    I tried already to implement dialog from ADF with launchDialog function.
    But ReturnListener did not function while I launch the Dialog manually.
    Anna

  • How  can  I use Javascript code to affect the display of textField?

    Hi All,
    I created a web application using JSF.
    And Placed two controls: one Text Field and one Label.
    On the Javascript onclick event of Label, I wrote the following javascript:
    document.getElementById("form1:textField1").value="test123";
    I run the web application, and click on the label, However, the text of the Text Field does not change.
    But the following code shows text of the Text Field has been changed. it works.
    alert(ocument.getElementById("form1:textField1").value);
    So, why the display of the Text Field does not change? How to update the display of the Text Field?
    Any suggestion will be helpful!
    Thank you.

    here is a full and correct example, enjoy
    1. <html>
    2. <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    3. <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    4. <f:view>
    5. <head>
    6. <title>
    7. <h:outputText value="#{msgs.windowTitle}"/>
    8. </title>
    9. </head>
    10. <body>
    11. <h:form id="registerForm">
    12. <table>
    13. <tr>
    14. <td>
    15. <h:outputText value="#{msgs.namePrompt}"/>
    16. </td>
    17. <td>
    18. <h:inputText/>
    19. </td>
    20. </tr>
    21. <tr>
    22. <td>
    23. <h:outputText value="#{msgs.passwordPrompt}"/>
    24. </td>
    25. <td>
    26. <h:inputSecret id="password"/>
    27. </td>
    28. </tr>
    29. <tr>
    30. <td>
    31. <h:outputText value="#{msgs.confirmPasswordPrompt}"/>
    32. </td>
    33. <td>
    34. <h:inputSecret id="passwordConfirm"/>
    35. </td>
    36. </tr>
    37. </table>
    38. <h:commandButton type="button" value="Submit Form"
    39. onclick="checkPassword(this.form)"/>
    40. </h:form>
    41. </body>
    42. <script type="text/javascript">
    43. <!--
    44. function checkPassword(form) {
    45. var password = form["registerForm:password"].value;
    46. var passwordConfirm = form["registerForm:passwordConfirm"].value;
    47.
    48. if(password == passwordConfirm)
    49. form.submit();
    50. else
    51. alert("Password and password confirm fields don't match");
    52. }
    53. -->
    54. </script>
    55. </f:view>
    56. </html>

  • How to call a bean method through javascript?

    Hi,
    i want to call a bean method using the javascript.
    thansk in advance.

    hi
    i want to call a backing bean method thought javscript on the button click.
    i am inplementing addition of textbox at runtime.i wrote method and i am calling that on the button click.but the textbox is not created.
    the code is bleow
    public String doAction() {
         tryStuff1();
    return "samplejsf";
    public void tryStuff1()
    System.out.println("Enter the trystuff method");
         FacesContext facesContext = FacesContext.getCurrentInstance();
    UIViewRoot uIViewRoot = facesContext.getViewRoot();
    Application application = facesContext.getApplication();
    UIComponent formComp=uIViewRoot.findComponent("subbody:form1");
    HtmlPanelGrid grid= new HtmlPanelGrid();
    grid.setId("panelgrid2");
    grid.setColumns(2);
    grid.setBorder(2);
    //UIComponent panelGridComp=formComp.findComponent("subbody:panelgrid1");
    //UIComponent panelGroupComp=panelGridComp.findComponent("panelgroup2");
         HtmlOutputText output = new HtmlOutputText();
    output.setValue("dynamic jsf text2");
    System.out.println("hello output text2");
    output.setRendered(true);
    grid.getChildren().add(output);
    HtmlInputText input = new HtmlInputText();
    input.setSize(40);
    input.setValueBinding("value", (ValueBinding) application.createValueBinding("#{sample.text2}"));
    input.setRendered(true);
    grid.getChildren().add(input);
    System.out.println("hello output text1");
    grid.setRendered(true);
    formComp.getChildren().add(grid);
    System.out.println("hello output text3:");
    formComp.getRendersChildren();
    formComp.setRendered(true);
    public boolean getRendersChildren() {
         return true;
    jsp code is
    <h:form id="form1">
    <h:panelGrid columns="2" binding="#{sample.formElements}">
    </h:panelGrid>
    <h:panelGrid id="panelgrid1" columns="1">
    <h:panelGroup id="panelgroup1">
    <h:outputText value="hardcoded jsf text1"/>
    <h:inputText value="#{sample.text1}"/>
    </h:panelGroup>
    </h:panelGrid>
    <h:commandButton id="add" action="#{sample.doAction}" value="add" type="SUBMIT"/>
    </h:form>
    when i click on the button its going into the method and diaplying s.o.p but the text box is not updated to the page.
    why is it so.
    i thought there may be a problem in calling the method directly thru button. i want to try thru javascript calling the bean method.
    why is the page not updated.
    can u help me out
    thanks in advance
    sree

Maybe you are looking for

  • How do i get pic to my pc with icloud

    how do get my pic to my pc bye using icloud thanks

  • Features I Would Like to Have

    Hi! Is there a specific place where to post desired phone features? Anyway, the feature I would like to see in next series60 phones is the ability to set memory option for the Archive message folder independently of what is set for other message fold

  • Business Connector Scenario .

    Hallo , I have been given a  scenario, where SRM sends a PO sheet in XML format to BC.I have to map some elements of the XML to the elements of client's application. They require the xml to be ftp ed to FTP server, from there it's used for applicatio

  • Output file

    hi everybody I try to create an output file using a sql query in a pl/sql script. I don't know how to get this file. from a simple sql query with spool filename, execute query and spool off, it's easy but inside a pl/sql script, I have no idea. Could

  • ColdFusion could not delete the file

    Good day all im getting this error. cant figure it out "ColdFusion could not delete the file c:\ColdFusion8\wwwroot\Jewel\images\stock\203083.jpg for an unknown reason" I tried installing the 801 update the patch using : http://kb.adobe.com/selfservi