TheCoder4eu / BootsFaces-OSP

BootsFaces - Open Source Project
Apache License 2.0
246 stars 102 forks source link

commandButton in normal form tag <form> #1053

Closed cavalka closed 4 years ago

cavalka commented 5 years ago

I get following error when using bootfaces commandButton in normal form tag. The plain JSF comandButton and Primefaces command button do not get this error.

javax.servlet.ServletException: CommandButton : 'j_id_e' must be inside a form element

Here is code. It is basically the signon example with converted to plain form tag.

<form method="post" action="j_security_check">
                <h2 class="form-signin-heading">Please sign in</h2>
                <b:inputText id="j_username" placeholder="Email address" >
                    <f:facet name="prepend">
                        <b:icon name="user" />
                    </f:facet>
                </b:inputText>

                <b:inputText id="j_password" placeholder="Password" type="password">
                    <f:facet name="prepend">
                        <b:iconAwesome name="key" />
                    </f:facet>
                </b:inputText>
                <b:selectBooleanCheckbox value="true" caption="remember me"/>
                <b:commandButton look="primary btn-block" value="Sign In" icon="log-in" size="lg" /> 
          </form>
geopossachs commented 5 years ago

Hello,

you can use Pass-Through Elements <form jsf:id="from"

<html ... xmlns:jsf="http://xmlns.jcp.org/jsf`

        <form jsf:id="from" method="post" action="j_security_check" >

            <h2 class="form-signin-heading">Please sign in</h2>
            <b:inputText id="j_username" placeholder="Email address" >
                <f:facet name="prepend">
                    <b:icon name="user" />
                </f:facet>
            </b:inputText>

            <b:inputText id="j_password" placeholder="Password" type="password">
                <f:facet name="prepend">
                    <b:iconAwesome name="key" />
                </f:facet>
            </b:inputText>
            <b:selectBooleanCheckbox value="true" caption="remember me"/>
            <b:commandButton look="primary btn-block" value="Sign In" icon="log-in" size="lg" />

        </form>

https://docs.oracle.com/javaee/7/tutorial/jsf-facelets009.htm

stephanrauh commented 4 years ago

Actually, I suspect you don't really need a <b:commandButton>. That's only necessary if the button invokes some action on the server (i.e. it has an action, an actionListener or one of the onXXX="ajax:myBean.myMethod attributes).

Just use a simple <b:button>, and everything should work.