[jboss-user] [JBoss Seam] - Re: Problem with update
adriju
do-not-reply at jboss.com
Tue Feb 12 04:36:30 EST 2008
I've got this:
<h:selectOneMenu id="grupoUsuario1" required="true" value="#{usuariosHome.instance.gruposUsuarios.nombreGruposUsuarios
| }">
| <s:selectItems value="#{usuariosEditBean.listaGruposUsuarios}" var="t" label="#{t}" /> </h:selectOneMenu>
And the bean is:
| @Stateless
| @Name("usuariosEditBean")
| @Scope(EVENT)
| @Restrict("#{identity.loggedIn}")
| public class UsuariosEditBeanAction implements UsuariosEditBeanInterface, Serializable
| {
| private static final long serialVersionUID = 1L;
|
| @Logger
| Log log;
|
| @In
| Identity identity;
|
| @PersistenceContext
| private EntityManager em;
|
| @Out
| private List<String> listaGruposUsuarios = new ArrayList<String>();
|
| @Out
| private List<Short> listaPrioridades = new ArrayList<Short>();
|
| public List<String> getListaGruposUsuarios()
| {
| List results = em.createQuery("select gruposUsuarios from GruposUsuarios gruposUsuarios")
| .getResultList();
|
| if (listaGruposUsuarios.size() != 0)
| {
| listaGruposUsuarios.clear();
| }
|
| if (results.size() == 0)
| {
| listaGruposUsuarios = null;
| return listaGruposUsuarios;
| }
| else
| {
| GruposUsuarios grupo;
|
| for (int i = 0; i < results.size(); i++)
| {
| grupo = (GruposUsuarios)results.get(i);
| listaGruposUsuarios.add(grupo.getNombreGruposUsuarios());
| }
| return listaGruposUsuarios;
| }
| }
|
| public List<Short> getListaPrioridades()
| {
| Short aux;
|
| listaPrioridades.clear();
|
| if (identity.hasRole("Administrador"))
| {
| aux = 10;
| listaPrioridades.add(aux);
| aux = 20;
| listaPrioridades.add(aux);
| aux = 30;
| listaPrioridades.add(aux);
| aux = 40;
| listaPrioridades.add(aux);
| }
| else if (identity.hasRole("Supervisor"))
| {
| aux = 30;
| listaPrioridades.add(aux);
| aux = 40;
| listaPrioridades.add(aux);
| }
| else if (identity.hasRole("Configurador"))
| {
| aux = 30;
| listaPrioridades.add(aux);
| }
| if (identity.hasRole("Visualizador"))
| {
| aux = 40;
| listaPrioridades.add(aux);
| }
|
| return listaPrioridades;
| }
|
| public GruposUsuarios selectGruposWhereNombreGruposUsuarios(String g)
| {
| GruposUsuarios grupo;
|
| List results = em.createQuery("select g from GruposUsuarios g where g.nombreGruposUsuario="+g)
| .getResultList();
|
| if ( results.size()==0 )
| {
| log.info("Grupo '#0' no está en la DB", g);
| grupo = null;
| }
| // Si existe...
| else
| {
| log.info("Grupo '#0' sà está en la DB", g);
| grupo = (GruposUsuarios) results.get(0);
| }
|
| return grupo;
| }
| }
I catch all the groups and put them in the selecItems, with their name.
Thanks for the reply, nickarls.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4128643#4128643
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4128643
More information about the jboss-user
mailing list