Ok, I've been discusing this with my colleages, and we can't find if what we are doing is ok or not, supose you have this view,
<h:form id="UsuarioEditForm">
<h:panelGroup id="display" styleClass="createPanelGrid">
<p:panelGrid columns="2">
<p:outputLabel value="Nombre de Usuario: " for="nombreUsuario" />
<p:inputText id="nombreUsuario" value="#{usuarioController.selected.nombreUsuario}" required="true" requiredMessage="Nombre requerido."/>
<p:outputLabel value="Contraseña: " for="password" />
<p:password id="password" value="#{usuarioController.selected.password}" required="true" requiredMessage="Contraseña requerida."/>
<p:outputLabel value="Correo Electrónico: " for="email" />
<p:inputText id="email" value="#{usuarioController.selected.email}" required="true" requiredMessage="Correo electrónico requerido."/>
<p:outputLabel value="Tipo de Usuario: " for="tipoUsuario" />
<h:selectOneMenu id="tipoUsuario" value="#{usuarioController.selected.tipoUsuario}" required="true" requiredMessage="Tipo de Usuario requerido." converter="#{tipoUsuarioConverter}">
<f:selectItem itemLabel="Seleccionar..."/>
<f:selectItems value="#{tipoUsuarioController.items}"
var="tipoUsuarioItem" itemValue="#{tipoUsuarioItem}" itemLabel="#{tipoUsuarioItem.tipo}" />
</h:selectOneMenu>
</p:panelGrid>
<p:separator></p:separator>
<p:commandButton styleClass="ui-priority-primary" actionListener="#{usuarioController.save}" value="Guardar" update="display,:UsuarioListForm:datalist,:growl" oncomplete="handleSubmit(xhr,status,args,UsuarioEditDialog);"/>
<p:commandButton value="Cancelar" type="button" onclick="UsuarioEditDialog.hide()"/>
</h:panelGroup>
</h:form>
the main managed bean who control the whole operation is called usuarioController
, this bean do the logic to insert a Usuario
entity, but, this entity needs a TipoUsuario entity for correct insert, so we have another bean called tipoUsuarioController
that get the list of TipoUsuario
entity and display it in a selectOneMenu where the user choose one TipoUsuario
, so, the question is simple, it's ok to call a bean just to perform the operation to get the TipoUsuario
List?, or it's better to get the List inside the usuarioController
bean? Which operation is the best for the application performance?.
Thanks,