Invoking a command link's action from a javascript, on pressing enter key

i have the foll java script function. on pressing enter within an input field i want a certain commandlink's action to be automatically performed:
function checkKeycode() {
     alert("entered");
          var keycode;
          if (window.event) keycode = window.event.keyCode;
          //else if (e) keycode = e.which;
          if(keycode==13){               
               alert("keycode: " + keycode);           
               var x=document.getElementById("form10:link1");
               alert("about to click");
               x.click();
               //document.forms[0].link1.click();               
               //if(validate('form1:_system_username,form1:_system_password','form1:_id0,form1:_id1','2'))
                    //alert("about to submit page");
                    //submitPage();
     }This fn is being called from the input text as follows:
<h:inputText styleClass="inputText" id="text1" size="32" onkeypress="checkKeycode();"></h:inputText>And the code containing the command link who's action i want to be called is:
<h:commandLink styleClass="commandLink" id="link1"
                         action="#{pc_Test.doLink1Action1}">
                         <hx:graphicImageEx border="0" styleClass="graphicImageEx"
                              id="imageEx1" url="../../images/search.gif"></hx:graphicImageEx>
                    </h:commandLink>
The javascript is being entered as i get an alert saying that enter key was pressed. However it is not performing the action requried, saying that "null is null or not an object"
could sumone please help????

Hi
From your javascript , it is known that this is only work in IE,
And indeed it works fine, mybe there is another button which the default in your jsp
Change your code like this:
onkeypress="return checkKeycode();"
and at end of your javascript return false when you call x.click
Message was edited by:
okoi80

Similar Messages

  • Command link / button action is not taking place if i use it in iterator.

    Hi,
    I am new to ADF, i am facing 1 issue while implementing ADF mobile browser application.
    Issue: command link / button action is not taking place if i use it in iterator. its just refreshing the page it self and displaying as no records.
    Scenario is i am populating the search results in results page from search page using iterator, i want to get the complete details in different page (results page -> details page) .
    I have tried in different ways.like
    case1:
    <tr:panelGroupLayout id="pgl2" layout="vertical" styleClass="af_m_panelBase">
    <tr:panelHeader text="#{classviewBundle.SEARCH_RESULTS}" id="ph1"/>
    <tr:iterator id="i1" value="#{bindings.SubjectVO1.collectionModel}" var="subject"
    varStatus="subIndx" rows="100">
    <tr:panelBox text="#{subject.Subject} #{subject.CatalogNbr} - #{subject.CourseTitleLong}"
    styleClass="af_m_listingPrimaryDetails" id="pb1">
    <f:facet name="toolbar"/>
    <tr:table var="ssrClass" rowBandingInterval="1" id="t1" value="#{subject.children}"
    varStatus="clsIndx" rowSelection="none"
    binding="#{SessionBean.subjectTable}" verticalGridVisible="true"
    emptyText="No Records" width="100%">
    <tr:column id="c9" sortable="false" styleClass="width:100%">
    <*tr:commandLink text="Section: #{ssrClass.ClassSection}-#{ssrClass.SsrComponentLovDescr} (#{ssrClass.ClassNbr})"*
    id="commandLink2" styleClass="af_m_listingLink"
    *action="#{pageFlowScope.BackingBean.searchaction}"></tr:commandLink>*
    //remaining code
    in this case commandlink action is not able to invoke serachaction() method
    case 2:
    <tr:commandLink text="Section: #{ssrClass.ClassSection}-#{ssrClass.SsrComponentLovDescr} (#{ssrClass.ClassNbr})"
    id="commandLink2" styleClass="af_m_listingLink"
    action="classdetails}"></tr:commandLink>
    in this case its not able to navigate to classdetails page.
    I gave correct navigation cases and rules in taskflow,but its working fine when the command link is out of iterator only.
    i tried with actionlistener too.. but no use.. please help me out of this problem .
    *Update to issue:*
    The actual issue is when i use command link/button in an table/iterator whose parent tag is another iterator then the action is not taking place.
    the structer of my code is
    < iterator1>
    #command link action1
    < iterator2>
    #command link action2
    </ iterator2>
    < /iterator1>
    #command link action1 is working but "#command link action2" is not...
    Thanks
    Shyam
    Edited by: shyam on Dec 26, 2011 5:40 PM

    Hi,
    To solve my problem I used a af:foreach instead.
    <af:forEach items="#{viewScope.DataBySubjectServiceBean.toArray}" var="text">
    <af:commandLink text="#{text.IndTextEn}" action="indicator-selected" id="cl1">
    <af:setActionListener from="#{text.IndCode}" to="#{pageFlowScope.IndicatorCodeParam}" />
    </af:commandLink>
    </af:forEach>
    By the way you need to convert the iterator to an Array using a ManagedBean.
    public Object[] toArray() {
    CollectionModel cm = (CollectionModel) getEL("#{bindings.TView1.collectionModel}");
    indicators = new Object[cm.getRowCount()];
    for(int i=0;i<cm.getRowCount();i++){
    indicators[i] = cm.getRowData(i);
    return indicators;
    public static Object getEL(String expr) {
    FacesContext fc = FacesContext.getCurrentInstance();
    return fc.getApplication().evaluateExpressionGet(fc,expr,Object.class);
    Hope that helps-
    Edited by: JuJuZ on Jan 3, 2012 12:23 AM
    Add getEL Method

  • In the address bar where type the address of the web site at the top. after entering the address i press enter key from the keyboard but it does'nt work there . Means the page is not navigating towards the address. Kindly solve the problem

    In the address bar where type the address of the web site at the top. after entering the address i press enter key from the keyboard but it doesn't work there . Means the page is not navigating towards the address. Kindly solve the problem

    This issue can be caused by an extension that isn't working properly.
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * [[Troubleshooting extensions and themes]]
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)

  • How to select an item from a dropdown menu using Enter key

    A website I frequently use opens with a dropdown menu. Using my former browser, I was able to select the an item from the dropdown list by hitting the first letter with my keyboard and then hitting Enter. (Think of entering an address and selecting TX from a dropdown menu of states. Often you can hit T twice to get to TX and then the Enter key will advance the cursor to the zip code field.) Since converting to Firefox, the Enter key no longer works to advance to the next screen...I now have to move the mouse to a "Go" button and click it after selecting the desired item from the downdown menu. It's a small thing, but constantly switching back and forth between mouse and keyboard is becoming annoying. Is there an option in Firefox to select items simply by highlighting them in the dropdown menu and hitting the Enter key, instead of having to use the mouse to click a "Go" button? Thanks

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    If it does work in Safe-mode then disable all extensions and then try to find which is causing it by enabling one at a time until the problem reappears.
    * Use "Disable all add-ons" on the [[Safe mode]] start window to disable all extensions.
    * Close and restart Firefox after each change via "File > Exit" (Mac: "Firefox > Quit"; Linux: "File > Quit")
    In Firefox 4 you can use one of these to start in <u>[[Safe mode]]</u>:
    * Help > Restart with Add-ons Disabled
    * Hold down the Shift key while double clicking the Firefox desktop shortcut (Windows)
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes

  • Can mouse action replace the function of pressing ENTER?

    hi there,
    I would like to use the mouse click on the textfield to substitute the pressing <ENTER> action on the textfield, since i want the user to use mouse only but i don't have place to put button already. Is it possible to do so?
    thanks

    You can do it, but it wouldn't make for a very conventional user interface. Just add a mouse listener to the text field and respond to click events the same way you'd respond to the enter key being pressed.
    myTextField.addMouseListener(new MouseAdapter()
      public void mouseClicked(MouseEvent e)
        // Now do whatever you'd do if enter was pressed
    });However, this is poor GUI design.

  • How to get a character from input stream withjout pressing RETURN key?

    In C, we could use getch() form <conio.h> to get a character from the input steam without pressing the return/enter key. How could I tranlate this function for use in Java?

    public static char readChar()
    int charAsInt = -1; //To keep the compiler happy
    try
    charAsInt = System.in.read();
    catch(IOException e)
    System.out.println(e.getMessage());
    System.out.println("Fatal error. Ending Program.");
    System.exit(0);
    return (char)charAsInt;
    }

  • Cannot Boot From Optical Drive By Pressing Keyboard Keys

    I finally went from Leopard to Snow Leopard (SL) by doing a clean install.  But I found I was not able to boot from the install disk by the normal procedure -- restarting and pressing the Option or C keys.  Before the SL install, I had a volume structure problem on my HD and tried to use the Leopard install DVD to repair the drive.  I was unable to do that by using the normal boot up procedure.
    Any ideas on why I can't boot from the optiical drive by pressing the designated keyboard key(s)?

    You can load your EFI firmware from here (get the correct version!)
    https://support.apple.com/kb/HT1237
    And use this method to install it
    https://support.apple.com/kb/HT2213
    I'll admit  frankly I don't know exactly what goes on in the deeper levels of Mac.
    I do know this when a Mac first boots it:
    1: Does a POST test, memory etc.
    2: Runs hardware firmware
    3: Runs EFI firmware loaded into special memory from the EFI partition (now erased in your case)
    4: Boots OS X
    I also know it takes two reboots to get the changes in EFI to "stick" as I've installed programs into EFI for special booting attributes.
    SO what I'm thinking here is you cleared your EFI special memory by not haviing a EFI partition anymore and rebooting twice???
    Perhaps your firmware wasn't installed correctly before?
    I've never encountered a problem like yours, it's exceedingly rare, however Apple does offer the links above for some reason one needs to reinstall their EFI firmware, I only assume it goes into the special memory or on a new EFI partiton on the boot drive it might create.
    Sorry but that's the extent of my knowledge, Lion killed my test machine so I can't replicate your issue to fix it.
    I hope that assists, please get back if it worked.

  • Exiting from a FORM while pressing ESC key !

    Hiiiiii !
    I am using Forms 6i. Is there any way that i may exit from a form while just pressing the ESC key ?
    Capri !
    Message was edited by:
    Capri

    when you start your runform via
    ifrun60.EXE myForm pa_username=myUser
    you can use this parameter for your new Resource-File, which you have saved from within Oracle Terminal :
    ifrun60.EXE myForm pa_username=myUser term=myTermFile.res
    try it
    Gerd

  • Invoking ADF Actions from JS API

    Is there a way to invoke an action from a javascript function? Something that would perhaps mimic what this commandLink does:
    <af:commandLink text="Lights, Camera, Action!"
    id="chuckNorris" action="flyingKick"/>
    What I am looking for is the ability to invoke the action "flyingKick" from a javascript function.

    Thanks, I actually already saw this. What I need though is something that doesn't a serverListener though - a programmatic version of a commandLink with an action if you will.

  • Resetting the id of dynamically generated JSF custom command link

    I have a java faces page which displays data from an arraylist.
    This list is populated when user inputs data in the input text field and clicks "Add Group" button.
    The arralylist consist of another arraylist within the former.
    I have created a custom command link for the former arraylist.
    As an user can add data to the arraylist so can he remove it from the arraylist.
    The command link has a method binding "closeTask" which is invoked when command link is clicked.
    This action removes the clicked element from the arraylist and displays the fresh list.
    The key field from the bean in the former arraylist is set in request, and is retrieved in the "closeTask" method to be assigned to the command link output text id (i.e. it identifies the element that is to be deleted from the arraylist).
    This functionality does not work as expected, i.e. command link component is not created/rendered during deletion as it is created while addition.
    As a result eventhough the element is removed from the arraylist, the id corresponding to the fresh arraylist is not refreshed and for further actions correct id is not passed and the deletion function does not work.
    How can I have resolve this problem?
    The sample code is included.
    Thanks in advance.
    Java Faces Code:
    <%
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Application app = facesContext.getApplication();
    Bkbean bean = (Bkbean)app.createValueBinding("#{bckbean}").getValue(facesContext);
    List aList = bean.getAList();
    if(aList!=null && aList.size()>0) {                                                            
    for(int i=0; i<aList.size(); i++) {
    ABean abean = (ABean) aList.get(i);
    int keyValue = abean.getKey();
    request.setAttribute("key", String.valueOf(keyValue));
    %>
    <TR>
    <TD width="90%">
    <%=abean.getCtg()%>
    </TD>
    <TD width="9%">
    <%=abean.getKey()%>
    </TD>
    <TD width="1%" align="right" valign="top">
    <h:commandLink binding="#{bckbean.commandLnk}" styleClass="commandLink">
    </h:commandLink>
    </TD>
    </TR>
    <%
    List dList = abean.getDList();
    if(dList!=null) {
    for(int j=0; j<dList.size(); j++) {
    String tData = (String) dList.get(j);
    %>
    <TR>
    <TD width="90%">
    <%=tData%>
    </TD>
    <TD width="10%" colspan="2">
    </TD>
    </TR>
    <%
    }%>
    <%
    %>
    <TR>
    <TD align="right">
    <h:inputText id="inputtxt001" value="#{bckbean.val}"></h:inputText>
    </TD>
    <TD align="left" colspan="2">
    <hx:commandExButton type="submit" value=" Add Group " styleClass="commandExButton" id="submitbtn001" action="#{bckbean.addVal}">
    </hx:commandExButton>
    </TD>
    </TR>
    Backing Bean Code:
    public void closeTask(ActionEvent event) {
    String key = "";
    UIOutput lnkTxt = null;
    UICommand comp = (UICommand)event.getComponent();
    if(comp.getChildren() != null && comp.getChildren().size() >0) {
    for (int i=0; i<comp.getChildren().size(); i++) {
    lnkTxt = (UIOutput)comp.getChildren().get(i);
    key = lnkTxt.getId();
    int selectedKey = (new Integer(key.substring(2))).intValue();
    if(aList!=null) {
    for(int i=0; i<aList.size(); i++) {
    ABean abean = (ABean) aList.get(i);
    if(abean.getKey()==selectedKey) {                                             
    aList.remove(i);
    break;
    public UICommand getCommandLnk() {
    String id = (String) request.getAttribute("key");
    UICommand commandLnk = new UICommand();
    commandLnk.setId("key" + id);
    UIOutput outTxt = new UIOutput();
    outTxt.setId("id"+id);
    outTxt.setValue("X");
    commandLnk.getChildren().add(outTxt);
    MethodBinding mb = app.createMethodBinding("#{bckbean.closeTask}", new Class[]{ActionEvent.class});
    commandLnk.setActionListener(mb);
    commandLnk.setImmediate(true);
    return commandLnk;
    }

    You cud define jsObjectNeeded and onClientClick properties for the htlm component and catch the event to find itz ID.
    This might help you:
    Accessing HTMLB form values from JAVASCRIPT
    To give you an idea abt how the code works:
    Portal: Bug in the  radio button's javascript api
    Regards,
    N.
    Plz click a star if it helped.

  • Command Link in the af:table Component can not Work in the Request Scope

    Actually, the problem is that when we click on the command link, the action method #{overview.goToLinkAction} is not triggered.
    Here is the codes of action method "goToLinkAction" on the backing bean:
    public String goToLinkAction() {
    String linkString = (String) AdfFacesContext.getCurrentInstance()
    .getProcessScope().get("linkString");
    System.out.println("Link String is: " + linkString);
    return "";
    The data object list "listOfTransefer" for af:table is composed first time when the page is initialized.
    public void onPageLoad() {
    this.listOfTransfers = composeListOfTransfers();
    But when the commandlink or commandbutton is clicked to pose the form, this onPageLoad method is ignored by using PagePhaseListener:
    public void beforePhase(PagePhaseEvent event) {
    FacesPageLifecycleContext ctx =
    (FacesPageLifecycleContext)event.getLifecycleContext();
    if (event.getPhaseId() == Lifecycle.PREPARE_MODEL_ID && needReload()) {
    bc = ctx.getBindingContainer();
    onPageLoad();
    bc = null;
    public final boolean needReload() {
    if (!isPostback())
    return Boolean.TRUE;
    else
    return alwaysReload();
    protected boolean isPostback() {
    return Boolean.TRUE.equals(resolveExpression("#{adfFacesContext.postback}"));
    That means the method "onPageLoad()" may not be invoked when the commandlink is clicked.
    Is there any way to resolve this problem without changing the scope of the backing bean to "session"?
    Your response will be very helpful for us.
    Thanks

    Hi,
    if you implicitly say that this works if the managed bean is in session scope then the problems seems to me that one of your evaluation criterias is reset in the request scope, which I think most likely is the needReload() method. Did you add debug statements to the methods to see where exactly it gets stuck?
    Frank

  • JS RangeError exception happens after click a command link in Chrome22

    Hi,
    I am using JDev 11.1.1.4. I got an JS exception after click a command link. Following is my steps.
    1. use chrome(V22) to access my app
    2. refresh page
    3. click a command link(with action property) in UI which can jump to another page
    Result: nothing happens, and since then click any command link does not work(page does not refresh and no reqeust is sent). But command button still works.
    If we do not refresh page, this does not happens.
    This case occurs always in Chrome and occasionaly occurs in FF.
    Troubleshoot:
    after refresh page, an ajax request is sent in ADF js framework. Respense is recieved and callback funtion is executed. Excetpion happens during callback function executing period.
    Watch call stack, the exception happens during removeComponent(name is like this) funtion.
    And finally, an exception is caught. Here is detal of exception:
    Excetption: RangeError, type: stack_overflow, stack: undefined.
    Any one got this case?
    Please give some help and guidance.
    Thanks

    Hi,
    if you have a customer support contract, can you file a service request with support and provide a test case ? Also, worth trying this with JDeveloper 11.1.1.6 first
    Frank

  • Action from bean called out from jsp form

    Hello, I''ve got problem: i have a form inside a jsp site. It is some searching form: i have inputtext and a "search" button.
    I have action connected with this button <h:commandButton id="search" value="Search" action="#{MyBean.searchj}"/>. It works fine when user press that button, the method from bean is been called out, but usually when user is using so kind of form, he press "enter" key instead of pressing "search" button.
    How can I bind (or call) bean method (in this example it is MyBean.search method) when after user writes something in inputtext and press "enter" key?
    Thanks in advance.

    It is a known problem in the current jsf-ri implementation. There is a component of the third party library that sovles this problem.
    See: http://www.jsftutorials.net/defaultActionTag.html
    You can use this library (it is free) or take the javascript code and insert it into your page.

  • Trigger Backing Bean Action from Java script

    Hello
    I'm quite new to JSF, Would like to know how we can trigger a bcaking bean action method using java script as part of form submit.
    Already I added one commandbutton with an action method defined in backing bean, But our requiremnt is to trigger the same action even if the user submits form by pressing Enter key.
    Targeted device is Windows Mobile IE ( In IE Mobile, we can't track onkeydown, onkeyup, onkeypress, onmousemove, onmousedown and onmouseup event. )
    1. How the JSF binds a backing bean method with JSF commandButton control on runtime. I didn't find any hidden value corresponding to this commandButton.
    2.How we can trigger a bcaking bean action method using java script as part of form submit
    Thanks
    Jobinesh

    thanks a lot for the replies. I'll try it out.
    But one question, just because of curiosity
    1. How the JSF binds a backing bean method with JSF commandButton control on runtime. I didn't find any hidden value/or any other flag corresponding to this commandButton from the genarted html for the correspondant jsf soure.

  • Action for ENTER KEY is not working in alv grid output (Classical)

    Hi Experts,
      I have searched SDN around 8 hours and could not get any help on my below issue.
      I am developing ALV report using function module (Classical ALV). ALV output has 4 input enable fields, if user enters data in any of those fields and clicks on enter button from key pad..the remaining fields needs to be filled automatically.
      I am facing the issue with enter key, even if i press enter key in the output there is no action and hence no user command triggered. May be i am using wrong funcion code in wrong way.
      Could any one tell me what function code can we assign for ENTER action in PF-STATUS?
    Regards,
    Murali Mohan

    Hi
    Try this simple code, it works fine:
    TYPE-POOLS: SLIS.
    DATA: BEGIN OF ITAB1 OCCURS 0,
           BUKRS LIKE T001-BUKRS,
           BUTXT LIKE T001-BUTXT,
          END OF ITAB1.
    DATA: GT_FIELDCAT   TYPE SLIS_T_FIELDCAT_ALV,
          GT_REPID    LIKE SY-REPID.
    START-OF-SELECTION.
      SELECT BUKRS BUTXT INTO TABLE ITAB1
         FROM T001.
    END-OF-SELECTION.
      GT_REPID = SY-REPID.
      CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
        EXPORTING
          I_PROGRAM_NAME     = GT_REPID
          I_INTERNAL_TABNAME = 'ITAB1'
          I_INCLNAME         = GT_REPID
        CHANGING
          CT_FIELDCAT        = GT_FIELDCAT.
      CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
        EXPORTING
          I_CALLBACK_PROGRAM       = GT_REPID
          I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
          I_CALLBACK_USER_COMMAND  = 'USER_COMMAND'
          IT_FIELDCAT              = GT_FIELDCAT
        TABLES
          T_OUTTAB                 = ITAB1.
    FORM USER_COMMAND USING R_UCOMM     LIKE SY-UCOMM
                          RS_SELFIELD TYPE SLIS_SELFIELD.
      CASE R_UCOMM.
        WHEN 'ENTER'. MESSAGE I208(00) WITH 'Pressed ENTER key'.
        WHEN OTHERS.
      ENDCASE.
    ENDFORM.                    "USER_COMMAND
    FORM SET_PF_STATUS  USING RT_EXTAB TYPE SLIS_T_EXTAB.
      SET PF-STATUS 'LIST_ALV' EXCLUDING RT_EXTAB.
    ENDFORM.                    "SET_PF_STATUS
    Max

Maybe you are looking for

  • Planned delivery time issue

    Hello Experts, We have below requirement. Created sales order for a particular material. Planned delivery time is picked from info record for that material and PR has been created. We are converting PR into PO and the planned delivery time is fine. N

  • Is it possible to connect 2 accessories to an iPad at the same time?

    I use an iPad as a cash register.  I currently have a credit card reader connected to it and I have a bluetooth barcode scanner.  There is a lot of interference with the bluetooth device and so I would like to hard wire the scanner to the iPad as wel

  • ITunes was not installed correctly. Error 7 (Windows error 1114)dow error 1114dows

    Hi, My itunes on my computer is not working. Need your kind help and advice. Thanks Anwar

  • Best strategy to send faxes

    Hello, somebody can inform me, as which is the best strategy to send faxes, with a SAP R/3 Enterprise? I have installed an Exchange Server and WinFax pro v8.. We need a third party software solution? Thanks in advance...

  • Battery won't come out

    I fly every week and swap 2 batteries regularly with my MacBook Pro. Just tried to swap batteries and the battery will not come out! I've tried shaking it loose while holding both release levers open, but it won't budge. I thought of trying to pry it