This is the button call in the .xhtml view
<p:commandButton title="Nueva Solicitud"
styleClass="FLeft"
icon="fa fa-plus white"
actionListener="#{dispatchView.initCreate()}"
action="solicitud.xhtml"
update="item-list-form,messages"
value="Nueva Solicitud"/>
In the corresponding Bean the code is as follows:
@Named(value = "dispatchView")
@SessionScoped
public class DispatchRequestController extends RequestController implements Serializable {
....
@Override
public void initCreate() throws IllegalStateException, SecurityException, SystemException, IOException {
creating = true;
editing = false;
selectedItem = new Request();
selectedItem.setCode(configService.getDocumentNextCode(Document.TYPE_DE_SEM));
selectedItem.setDateRequest(LocalDate.now());
selectedItem.setSourceArea(areaService.findOneById(Area.AREA_MATPRIM1));
selectedItem.setDestinationArea(areaService.findOneById(Area.AREA_DESPACHO));
details.clear();
selectedItem.setRequestDetails(details);
}
....
}
The Bean it extends from is a RequestController with this structure.
@Named(value = "requestView")
@SessionScoped
public class RequestController extends BaseController implements Serializable {
...
public void initCreate() throws IllegalStateException, SecurityException, SystemException, IOException {
creating = true;
editing = false;
selectedItem = new Request();
selectedItem.setCode(configService.getDocumentNextCode(Document.TYPE_MP_SEM));
selectedItem.setDateRequest(LocalDate.now());
selectedItem.setSourceArea(areaService.findOneById(Area.AREA_ALMUEB));
selectedItem.setDestinationArea(areaService.findOneById(Area.AREA_MATPRIM1));
details.clear();
selectedItem.setRequestDetails(details);
}
...
}
And the BaseController has the following structure.
@ViewScoped
public class BaseController implements Serializable {
....
}
The RequestController has similar behavior and works perfectly. Please someone explain to me how to solve this problem. Thank you very much.
The need to press the commadButton twice to make the call was due to a programming error in the .xhtml view, since an include is made to a file that has a modal but said include was made before the form tag of the main view, leaving the form tag of the modal inside the form tag of the view, generating this incompatibility that is so difficult to detect.