TheCoder4eu / BootsFaces-OSP

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

Create a <b:footer> that displays its content regardless of whether it's inside an <h:form> #417

Closed Robblle closed 5 years ago

Robblle commented 8 years ago

If you have an <h:form> around a <f:facet type="footer"/> inside a <b:modal> all the footer's contents are not being displayed.

<b:modal id="modal" title="Test" styleClass="testModal"
                     closable="false" close-on-escape="false" backdrop="true">
    <h:form>
          <f:facet name="footer">
                  <b:button value="Close" dismiss="modal" onclick="return false;"/>
          </f:facet>
    </h:form>
</b:modal>`
TheCoder4eu commented 8 years ago

Hi @Robblle , Thank you for opening this issue. Well, since you provided a complete example I can now answer you without doubts:

you are trying to use the b:modal "footer" facet in a h:form, but there is no such facet defined for h:form, so it doesn't know how to handle it and thus, it does not render its contents.

This is by JSF design: you can't use a facet of a component in a nested component.

stephanrauh commented 8 years ago

@Robblle Is there any reason why you want to put the footer in a form?

Robblle commented 8 years ago

I wanted to have a save and cancel button inside a modals footer

zhedar commented 8 years ago

@Robblle You don't have to put that button into an own form. Just use an enclosing one and limit the button's scope (out of the top of my head, I would recommend setting process="@this" or immediate="true").

stephanrauh commented 8 years ago

Both process="@this" and immediate="true" are fine for the cancel button, but nor for the save button :).

stephanrauh commented 8 years ago

BTW, sounds like a valid use case to me. As a workaround, you can put the entire model into a form as @zhedar suggested.

zhedar commented 8 years ago

@stephanrauh Oops, I've really thought about the cancel button here, because that's the only challenge in this scenario. The save button should include the whole form anyway.

stephanrauh commented 8 years ago

Well, but that was the problem. I suppose @Robblle created a form within the modal, and then tried to add the buttons in the footer. You can put the footer in the form because BootsFaces doesn't detect it there. You can't put a b:commandButton outside a form because JSF doesn't allow that. So you end up defining a footer consisting of a form containing two buttons. Now the "Save" button submit precisely this form. It doesn't know it's intended to send the input field above the header because that's another form.

So I'm currently pondering whether we should teach BootsFaces to look for the header in the form, too.

michbeck100 commented 7 years ago

Was there any work on this issue? I stumbled upon the same problem and i think its a common use case to have a b:commandbutton as save button.

stephanrauh commented 7 years ago

Just put it the other way round, and everything works:

<b:modal id="modal" title="Test" styleClass="testModal"
                     closable="false" close-on-escape="false" backdrop="true">
     <f:facet name="footer">
         <h:form>
                  <b:button value="Close" dismiss="modal" onclick="return false;"/>
          </h:form>
     </f:facet>
</b:modal>
michbeck100 commented 7 years ago

I'm using a b:commandbutton and i would like to process every inputs with "@form". This won't work this way. I can still process another, i know, but i think this is a little bit confusing.

stephanrauh commented 5 years ago

I suppose you can solve the issue using one of the BootsFaces search expressions. Let's close this ticket.