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.