I have a view where I have a form with p:commandButton
and everything works fine beacuse I'm using forward
and that's what I need:
<h:form id="formularioAltas">
// More code
<p:commandButton value="Guardar" action="#{altasBean.agregarRefaccion()}" update="cboAlmacen cboEstado cboCategoria" />
</h:form>
The method agregarRefaccion()
is void so does not changes the page, I think a forward
takes place after that action because it always has the same url. That is Ok beacuse that is what I need.
In the same view a have another form where I have a problem with h:commandButton
.
<h:form id="myForm" enctype="multipart/form-data" prependId="false">
// More code
<h:commandButton id="button" style="background-color: black; color: aliceblue" value="Guardar imagen para #{altasBean.refaccion.idRefaccion}" action="#{altasBean.subirImagen()}" />
</h:form>
The subirImagen()
method is void too so I thought a forward would take place after that action... but it doesn't. The page updates and the url changes so that means a redirect did that.
I will always need a forward. No matter if it is a p:commandButton
or a h:commandButton
.
I think has something to be with PrimeFaces and the differences of p:commandButton
with JSF h:commandButton
.
So I need a forward in that h:commandButton
.
Edit
I always have an url like this blabla/AlmacenGM/
but when h:commandButton
goes the url is: blabla/AlmacenGM/faces/altas.xhtml
The url changes. I have tried to return the string "altas"
int the method subirImagen()
so a forward should take place but it still changing the url.
Any ideas?