You need to sign in to do that
Don't have an account?
wesnolte
Pressing enter on form with commandlink doesn't submit form
Hello
I have a form that contains an inputtext and a commandlink that submits the form when clicked. I have noticed that if I press the enter key after entering text in the inputtext the page just refreshes. If I change the commandLink to a commandButton the form does submit, but I have certain reasons for using commandLink, so this is not feasible.
I have noticed this behaviour in another form on a seperate page too. Any ideas?
Wes
I should have posted some code hey;)
<apex:form id="seachForm">
<apex:inputText id="sInput" value="{!keywords}" />
<apex:commandLink target="_top" id="sBtn" value="Search" action="{!search}"/>
</apex:form>
Thanks for the suggestion but there isn't a rerender. I tried to use some javascript to simulate the behaviour ie. an onkeypressed even on the inputText that checked for key 13, but that was being a bit weird.
The HTML that is rendered is doesn't contain any type of buttons at all. But after following your advice and having a look at HTML I can see that they're using javascript to submit the form with the commandlink is clicked.
I think I may have to log a bug case.
Hai
Sample Program for command Link submit
Regards
Thanga
Computer says no.
I'm afraid this will not work. What I need is for the action method to return a pagereference when I press the enter key. Change your class like this and instead of clicking the link press enter when done typing,
public class TestBtnLinkController{
String inputValue;
public TestBtnLinkController(){
}
public String getInputValue(){
return inputValue;
}
public void setInputValue(String inputValue){
this.inputValue = inputValue;
}
public PageReference passParam(){
System.debug('inputValue :'+ this.inputValue );
return System.Page.Home;
}
}
The page will refresh. Now try changing the commandlink to a button and it works.
Thanks for the effort though,
Wes
Hey
I've logged a Case 02831282. If anyone knows any tricks in the meantime feel free to post as some times resolution on cases can be, um.. tardy.
Wes
I've found that if you omit the rerender parameter on an apex:commandButton tag, Salesforce will post the form. Otherwise, apex:commandButton and apex:commandLink will just invoke an ajax call to your action function.
If you need to run javascript form validation before calling your action function, just call it from the apex:commandLink onclick parm: