jsf - p:defaultCommand is autofired in Chrome -


i have strange behavior p:defaultcommand in chrome browser. in form password field, have p:commandbutton ajax="false" (to let browser show 'remember password') , p:defaultcommand allows send h:form enter key.

the problem appears when:

  1. enter username , password.
  2. send form (click on button or press enter)
  3. remember password (browser prompt)

now, when try access view, browser fill both fields (that ok, because have remebered credentias) in chrome, without clicking on button or pressing enter, form automatically send. why? in firefox , ie works well: form send when user click button or press enter, if field remebered browser.

the following code shows saying.

the view:

<!doctype html> <html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"> <h:head>     <meta charset="utf-8" />     <title>sample</title>     <meta name="viewport" content="width=device-width, initial-scale=1.0" /> </h:head>  <h:body>      <h:form>          <p:panelgrid columns="2">              <p:outputlabel value="username" for="username" />             <p:inputtext id="username" value="#{loginbean.username}" />              <p:outputlabel value="password" for="password" />             <p:password id="password" value="#{loginbean.password}" />                    </p:panelgrid>          <p:commandbutton id="sendbtn" value="send!" action="#{loginbean.login()}" ajax="false" />          <p:defaultcommand target="sendbtn" />      </h:form>  </h:body> </html> 

the bean:

@named @viewscoped public class loginbean implements serializable {      private static final long serialversionuid = 1l;      private string username;     private string password;      public string login() {         // simulate login         // send index create intentional cycle in chrome         return "/index?faces-redirect=true";     }      public string getusername() {         return username;     }      public void setusername(string username) {         this.username = username;     }      public string getpassword() {         return password;     }      public void setpassword(string password) {         this.password = password;     } } 

that undesired behavior, worst if making redirect same view sample, because chrome send form, login() method executed, , index.xhtml view rendered, again, , cycle repeated.

what wrong here? p:defaultcommand or chrome?


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -