Triggering a click event on an AdfRichCommandButton via JavaScript

Hi,
I have created a standard JAAS login page. To get it to work, I had to create a HTML <tt><form></tt> tag surrounded by a <tt><f:verbatim></tt> component. It works perfectly fine, except that there is no default button. In other words, it is not possible to submit the form by pressing enter. I'm looking for a way to add this functionality, I'll probably need to create som JavaScript, that usually would have been created by the <tt><af:form></tt> component.
This is how my page is defined now:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          xmlns:trh="http://myfaces.apache.org/trinidad/html">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document title="Login" id="d1"
                 theme="dark">
      <f:facet name="metaContainer">
        <f:verbatim>
          <script type="text/javascript">
          // JavaScript goes here...
          </script>
        </f:verbatim>
      </f:facet>
      <af:showPopupBehavior popupId="p1" triggerType="load"/>
      <f:verbatim>&lt;form action="j_security_check" method="POST"&gt;</f:verbatim>
      <af:popup id="p1" contentDelivery="immediate">
        <af:panelWindow id="pw1" title="Login"
                        closeIconVisible="false">
          <af:panelFormLayout id="pfl1">
            <af:inputText label="User name:"
                          required="true" id="j_username">
              <af:clientListener type="keyPress" method="checkEnter"/>
            </af:inputText>
            <af:inputText label="Password:"
                          required="true" id="j_password" secret="true"
                          rows="1">
              <af:clientListener type="keyPress" method="checkEnter"/>
            </af:inputText>
            <af:panelLabelAndMessage label="" id="btnbr">
              <af:commandButton text="Login" id="lb"
                                accessKey="L"/>
            </af:panelLabelAndMessage>
          </af:panelFormLayout>
        </af:panelWindow>
      </af:popup>
      <f:verbatim>&lt;/form&gt;</f:verbatim>
    </af:document>
  </f:view>
</jsp:root>As you can see, I have added a <tt><af:clientListener></tt> to each of the inputs. I've created a little JavaScript function to detect if the enter key is pressed:
function checkEnter(e) {           
  var characterCode            
  e = event;
  characterCode = e.keyCode;     
  if(characterCode == 13){    
    document.forms[0].submit() 
    return false
  } else {
    return true
}This works on IE, but not on FireFox. And it has the disadvantage that the "Login" button doesn't get disabled as soon as Enter is pressed. I tried to replace the <tt>document.forms[0].submit()</tt> part by something like this:
comp = AdfPage.PAGE.findComponent('lb');
comp.click();But nothing happens. I searched the documentation, but I can't find a way to trigger a click event on a AdfRichCommandButton. Does anyone have an idea how I could accomplish that the Login button is clicked if the user presses enter?
Best regards,
Bart Kummel
Edited by: Bart Kummel on Oct 21, 2009 9:29 AM

Hi,
there might be problem with popup. for me this login page works (and without f:verbatim). but of course without popup effect and seems like validation also doesn't work:
<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich"
          xmlns:c="http://java.sun.com/jsp/jstl/core"
          xmlns:trh="http://myfaces.apache.org/trinidad/html">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document title="Login" id="d1"
                 theme="dark" initialFocusId="j_username">
      <f:facet name="metaContainer">
      </f:facet>
      <form action="j_security_check" method="POST">
        <af:panelStretchLayout id="psl1" startWidth="50px" endWidth="50px"
                               topHeight="50px" bottomHeight="50px">
          <f:facet name="bottom">
            <af:spacer width="10" height="10" id="spacer3"/>
          </f:facet>
          <f:facet name="center">
            <af:panelBox text="Login" id="pb1" showDisclosure="false"
                         inlineStyle="width:300px; height:150.0px;">
              <f:facet name="toolbar"/>
              <af:panelFormLayout id="pfl1">
                <af:inputText label="User name:" required="true"
                              id="j_username"/>
                <af:inputText label="Password:" required="true" id="j_password"
                              secret="true" rows="1"/>
                <af:panelLabelAndMessage label="" id="btnbr">
                  <af:commandButton text="Login" id="lb" accessKey="L"/>
                </af:panelLabelAndMessage>
              </af:panelFormLayout>
            </af:panelBox>
          </f:facet>
          <f:facet name="start">
            <af:spacer width="10" height="10" id="s1"/>
          </f:facet>
          <f:facet name="end">
            <af:spacer width="10" height="10" id="spacer2"/>
          </f:facet>
          <f:facet name="top">
            <af:spacer width="10" height="10" id="spacer1"/>
          </f:facet>
        </af:panelStretchLayout>
      </form>
    </af:document>
  </f:view>
</jsp:root>regards,
Branislav

Similar Messages

  • SAP 2007 CheckBox Click Event

    Hi Pro,
       I created a checkbox in a Matrix on a form and set up a click event for the checkbox.  If I click once at a time slowly, the click event triggered as noraml.  If I click it twice fast, it only triggered the click event once, not twice.  Is it a bug in SAP 2007?
       One more thing, put a focus on that checkbox column in a matrix, then press the "UP" or "DOWN" arrow key, the focus goes to previous or next row, it works perfect, except why it triggers the click event as well?  Do you think this is wrong?
    Chris

    Hi Chris,
    When you click twice (fast), this translates to et_DOUBLE_CLICK event. Of course, et_CLICK is also fired.
    When you press the "UP" or "DOWN" arrow key, along with et_CLICK event, other events are also fired e.g. et_GOT_FOCUS, et_LOST_FOCUS etc.
    You can use Event Logger tool (part of B1DE) to look at all the events fired when a certain action is performed. This will help you determine which events you want to handle in your code.
    Regards
    Aravind

  • Project Server 2010 - Triggering event handler on click event of PDP

    Hi,
    We are trying to trigger an event handler/ process on click event of PDP page (similar to Project Details Page). Users do not have rights to checkin the project.
    So just on click event of pdp - an event handler or process should trigger.
    Could you please suggest me best possible way for the same? Thanks.
    Best Regards,
    Abhijit
    +91 8600577750

    There may be multiple reasons for this.
    1. SharePoint timer Job is malfunctioning:
    For this try restarting SharePoint timer Job. through SP Powershell:
    Stop SPTimerv4 , Start SPTimerv4
     2: SharePoint Cache is full:
    Reset SharePoint Cache by deleting all XML files ( except cache.ini
    )  in SharePoint Cache located in System Drive\ProgramData\Microsoft\SharePoint\Config\<GUID>
    3: Check if Microsoft Project Server Event Service is running in Services.msc, try restarting it.

  • Image button click event not triggered in IE11

    I have an Image button, on its click event textbox is displayed, but it is not working in IE 11. It is working fine on chrome

    Please post questions related to ASP.NET in the ASP.NET forums (http://forums.asp.net).

  • How do I convert the single x and y coordinates returned by a CWGraph Click event to the Cursor X and Y Positions?

    I am trying a work around for another problem.
    cwCSnapNearestPoint does not give me a CursorDown event (TrackMode = cwGTrackDragCursor). I need to know when the user has clicked on a Cursor. I need to figure out when the user has clicked on a cursor.
    The click event gives you coordinates as "Single" which are an OLE_XPOS_PIXELS. How do I convert to the Cursor coordinates (or vis a vis)?
    Or better yet is there another way to figure that a cursor has been clicked on (while using cwCSnapNearestPoint and TrackMode = cwGTrackDragCursor )

    Here are a couple potential fixes for the problem. If you are dealing with cursors on the graph, I would look into CursorChangeEvent, CursorMouseDown, CursorMouseUp, and CursorMouseMove. The ChangeEvent is triggered upon repositioning of the cursor. MouseDown triggers on the depression of a mouse button on a cursor, while MouseUp triggers on the button's release. MouseMove is triggered when the mouse is moved over a cursor. These each give X and Y positions in the arguments. If you used these and then made a Sanp to nearest point, you should have the coordinates before you sanpped to the point.

  • Possible bug - Missing click event when handling change event

    Using Flex 4.5 SDK, I have a spark ComboBox and a Button next to it for applying a filter according to ComboBox selection.
    I listen to both the ComboBox's change event & the Button's click event (for different functions).
    When I manually delete the ComboBox text value from its TextInput (i.e. changing selected index to -1) and immediately click on the Button,
    the click event-handler function is not being called and only the ComboBox's change event-handler function is executed.
    (Selecting a value from the ComboBox's list and clicking on the button triggers both methods on the right order.)
    There's also a state definition for the module, but it isn't being changed during these operations...
    Is this a bug or a correct behavior? Am I missing something here?
    Any workaround suggestions?
    (I thought of listening also to mouse-down or mouse-up on the button instead, but haven't tried it yet...)
    *** UPDATE ***
    When using the Button's mouseDown event the behavior is as expected, so there's a simple workaround.
    However, it seems to me like there's a bug with the Button's click event listener or something...
    *** UPDATE #2 ***
    I created a test application for that and couldn't reproduce the problem.
    Then I figured out the problem and solved it.
    It's a bit emmbarrasing, but I actually disabled the button (enabled=false) as in a child method of the change handling code...
    (If there is no value, don't allow applying the filter - It makes sense! )
    Anyway... No issue after all.
    However, I choose to leave this post (and not delete it) as an example of identifying and resolving a strange behavior in a complex application.

    There's no need.
    Please read the section UPDATE #2.

  • Sharepoint 2010 Custom Visual Webpart button click event firing on page refresh

    I have developed a Visual Webpart to create a list in SP using vs2010 and  the button click event I have written the list create method. If I click the button list is created successfully.  And I refresh the page again list is creating(Again button
    click event is triggering).please help me to solve the issue.
     protected void Button1_Click(object sender,
    EventArgs e)
                SPWeb web
    = SPContext.Current.Web;
                //SPList list=web.Lists["Auto"];
                SPList list
    = web.Lists[DropDownList2.SelectedItem.Text];
                if
    (string.IsNullOrEmpty(TextBox1.Text)
    || string.IsNullOrEmpty(DropDownList1.Text))
    Label4.Text =
    "Fields Are Empty";
                else
    if (DropDownList1.SelectedItem.Text
    == "Single line of Text")
                    list.Fields.Add(TextBox1.Text,
    SPFieldType.Text,
    true);
    SPView viewname = list.Views["All Items"];
                    viewname.ViewFields.Add(TextBox1.Text);
    //viewname.Update();
                    list.Update();
    Label4.Text =
    "Field Created Successfully";
    TextBox1.Text =
    string.Empty;
    // Label4.Text = string.Empty;

    Hi,
    This is because the request is sent to the server when you refresh the page.
    A workaround for this is that we can “provide a refresh link that redirects to the same page (or if you have some action causing the refresh programmatically, you could just
    redirect to the page after that, with Response.Redirect)
    so that page is requested by the browser (with GET method, default with hyperlinks)”.
    More information:
    http://social.msdn.microsoft.com/Forums/sharepoint/en-US/45648b39-1229-405c-ac9e-60eb82905982/click-event-getting-fired-on-page-refresh
    Or we can use the Session to save a value which used as a flag for us to check whether it is a page refresh and perform accordingly.
    http://www.codeproject.com/Articles/28099/Refresh-Page-Issue-in-ASP-Net
    http://www.codeproject.com/Articles/10240/Detecting-Page-Refresh
    Thanks
    Patrick Liang
    TechNet Community Support

  • CSS issues....get Javascript error on click event

    Trying to finish up this navbar. Got it where my navigation works pretty much great. However, the code I expected to work when I fire a click event on the logo (represnted currently by a gray circle) causes a 'Javascript error in event handler! Event Type = element' error instead. Not sure why. I know I had an issue with one of my button references (spelling issue) but beyond that, everything seems to be in order.
    This is the code I'm using. The first five lines work right. The second series does not.
    sym.getSymbol("btnVision").$("back").css({opacity: 0})
    sym.getSymbol("btnIndustires").$("back").css({opacity: 1})
    sym.getSymbol("btnResp").$("back").css({opacity: 1})
    sym.getSymbol("btnCommunity").$("back").css({opacity: 1})
    sym.getSymbol("btnDiscovery").$("back").css({opacity: 1})
    var stage = sym.getComposition().getStage()
    stage.$("navVision").css({top: 65});
    stage.$("navIndustries").css({top: 65});
    stage.$("navResp").css({top: 65});
    stage.$("navCommunity").css({top: 65});
    stage.$("navDiscovery").css({top: 65});
    I should mentioned I tried sym.getSymbol for the bottom entries but that simply produced the same exact error. Sign.
    Anyone know what might be causing this? It doesn't seem to make sense to me. Here's the files.
    https://www.dropbox.com/s/xo90u6hvj65ix78/nav.zip

    Hi ladobeugm,
    The error message is rather cryptic, but this occurs when trying to access something not defined, as you already experienced with your misspelling.
    You should use Firebug to localize the error via step by step execution. There is a Scripts tab. In its menu, select <youProject>Actions.js. Then, define a breakpoint by clicking in the line number of statement var stage= etc. In the Spies area, you can look for the offending statement by monitoring variable values.
    Gil

  • Click event for single column in DataGrid

    I can add an event listener to a DataGrid of type
    ListEvent.ITEM_CLICK, which is triggered when the user clicks any
    part of an entire row in a DataGrid. I want to trigger a click
    event for just one column. I only want to run a function when the
    user clicks in just the first column of the DataGrid, and not run
    trigger the event if they click in any other column. Any help would
    be much appreciated.

    Accessing the event.target returns the entire DataGrid, not
    the DataGridColum. Any way to get just the DataGrid column?

  • Kill the MouseEven.CLICK event when mouse is held down?

    I have been studying games on Facebook and am trying to emulate mouse event handling. For example in ChefVille you can click on objects and drag them around. But if you hold the mouse down you pan the entire game environment and when you release the mouse button a click is NOT registered on the object below the mouse. In my tinkering the CLICK event is triggered on the release of the mouse button no matter how long I keep the button depressed. How do I keep the CLICK event from firing if the mouse is held down for some period of time?

    I don't know that you can cancel a CLICK event in the middle of it happening (CLICK = MOUSE_DOWN followed by MOUSE_UP), but you can trigger a Timer on the MOUSE_DOWN event and use its event handler to set a boolean variable that your CLICK event handler function can make use of to decide whether or not to process a CLICK event.

  • What are the selections when defining a job triggered by an event?

    I use SM36 by defining a job triggered by an event. I click "Start conditions" button, then click "After event" button and place the event name.  I wonder if I would have to continue to click the button "Immediate" button and save it?  or just save it without clicking the "Immediate" button?
    Thanks and this question is urgent!

    Hi!
    No you only save and after define the step!
    If you click Immediate, your job start immediatelly and not after event.
    Max

  • Click Event Question - VB6 SDK 6.5

    A quick question for you guys:
    On the A/R Invoice form, I have a UDF that exists as a combo box.  I can trap the et_COMBO_SELECT event on that combo box just fine, however, I would like to generate a click event on the 'Name' field on the main form from the UDF et_COMBO_SELECT event.  The problem I'm running into is that because the form that contains the UDF has a different UID from the actual A/R Invoice main form, I get an error when I try to perform the click event on the 'Name' field.  The code I'm using is below.  Any help would be appreciated.
    Thanks,
    Greg
    '(A/R Invoice) Change value of eqp_DivisionCode global variable when combo select event triggers
    If eqp_pVal.FormType = -133 And eqp_pVal.FormMode = fm_ADD_MODE And _
       eqp_pVal.ItemUID = "U_Division" And eqp_pVal.EventType = et_COMBO_SELECT Then
       Set eqp_frm = SBO_Application.Forms.Item(FormUID)
       Set eqp_cmbDivision = eqp_frm.Items("U_Division").Specific
       eqp_DivisionCode = eqp_cmbDivision.Selected.Value
    End If

    Hi Greg,
    if you want to access a User Defined Field on a System Form but in header level you need to approach it as follows:
    If (pVal.EventType = et_FORM_LOAD And pVal.FormType = 139 And _
        pVal.Before_Action = True) Then
            Set oform = m_App.Forms.Item(FormUID)
            Dim oUsrForm As SAPbouiCOM.Form
            Dim num As Long
            Dim UDFformUID As String
            num = Right(FormUID, (Len(FormUID) - 2))
            num = num + 1
            UDFformUID = "F_" & num
            Set oform = m_App.Forms.Item(UDFformUID)
            oform.Items.Item("U_1").Specific.String = "Test"
        End If
    Regards,
    Lisa Mulchinock
    SAP SDK Consultant
    Galway

  • Click event (activate?) on images inside a GalleryView

    Hi,
    i tried few things in iAd Producer but now what i need to do is "go to page myPage" after taping/clicking on one of the images contained by a GalleryView.
    So i tried to handle this using the Activate event of my image layer, but the problem is that event is more like a didTouchDown event followed by a didTouchUpInside event than a true click event...
    Sorry if i'm not clear enough, what i mean is that if i touch the image then drag the GalleryView then release my touch from the image : the Activate event will be triggered... but what  i wanted to do was just drag the GalleryView.
    Does anyone know an alternative event that will be triggered only if the drag event is not triggered ?
    (I'm a developer, i can write some JS code if needed.)
    Thanks !

    Hi,
    You must be doing diffently than I am.  My gallery appears to be doing what you're looking for; swipe will change the gallery view (previous/next cell) and tap will activate my JS code.
    I have the gallery view with images on an iPhoen project.  The images in the 1st and 2nd cell have the onviewactivate event.  I just changed my image in my 2rd cell to got to page action.  Both behaves as expected on my iPod touch.
    If we can identify how you're doing differently, maybe we can help you.
    -Takayasu

  • Determining Tables on Double Click Event on Split Screen

    Hi,
    I have an OO split screen scenario where I display 2 different internal tables, 1 in the upper section of the split screen and the other in the lower section part. The layout structure used is the same for both internal tables since they display similar information. I am trying to establish that if I use the double click event to drill into specific line items, how do I determine which one of the split screens (and hence which internal table) have I double clicked on so that the correct internal tables details is read for further processing?
    Thanks

    Hi Uwe,
    Thanks very much for this. I have tried this out and it works perfect. However I'm trying to understand this further from the point of view that I did originally look at the event DOUBLE_CLICK in the class CL_GUI_ALV_GRID but didn't think I could use if further since there was no tie in with the optional parameter 'SENDER' you show. It only has 3 parameters listed for this so how does the 'SENDER' optional parameter work? Is this by reference/registration via the SET HANDLER statrement? I also debugged and looked at 'value' passed into the SENDER optional parameter... its not what I expected to see but contains what looked like the whole class object? Apologies but I'm coming more from years in the trenches of "classical" ABAP and seeing the light with ABAP OO!!
    Appreciate all your assistance.
    Thanks

  • Click event on DVT Line Graph

    Hi,
    Is it possible to attach a javascript click event on a DVT Line graph component?
    I know ADF DVT has clickListener but what happens is that it is triggered only when you click any of the series data but clicking the the column label or row label does not raised any event where I could add logic.
    What I want is that whatever part of the DVT Line graph is component it would call a managed bean method.
    Here's my use case:
    I am showing a list of DVT line graph and user needs to select at least one DVT Line Graph in the list. Clicking one of the Line Graph will highlight the background of that Line Graph.
    Obviously, I will just PPR the surrounding parent component of the selected Line Graph.
    As I have mentioned, the click listener is triggered only when clicking particular series in the graph.
    I am thinking if I could attach a javascript event for this and then fire up a server listener but I could find any information on how to do this.
    Is this possible?
    JDEV 11G PS5

    Bump....any hints? Please?

Maybe you are looking for

  • Office Web Apps Server on-premise PowerPoint SmartArt malfunction

    Hello. We're considering a Sharepoint deployment, and big part of this for us is editing via Office Web Apps. I'm implementing a lab deployment right now. Its all 2013 SP1 with latest updates. Everything works, however I've found the apps somewhat li

  • ITunes unknown error (-200) (and others)

    Just switched from a iPod mini to an older 20 gig. Tried to sync it. iTunes crashed. Made me reformat the iPod. Lost all music on it. Also, no audio was playing. Told me to update iTunes. (thinking it would solve the sync issue) I did. iTunes wont op

  • Cost centre without business area

    Hi All, I have document splitting with business area and profit centre mandatory, along with this i have configured business area wise FSV in OBY6. We have  configured 10 business areas and 5 profit centres, but i have  created cost centres without b

  • Can't use the Save As Reader Extended PDF option

    Hi team, I have exactly the same issue as was discussed here (http://forums.adobe.com/thread/865292) But I have lecensed Adobe Acrobat XI Pro. I use Create Form from Existing Document (no securyty restructions - see pictures below). I was able to use

  • MS Office Document Cache keeps failing repeatedly...

    The thread under title "The Microsoft Office cache encountered a problem (with Office 2013 ProPlus Preview/Beta)" described exactly my problem, but discussion on that thread has been locked without any solution to the problem. I'd like to add one sym