Boa noite pessoal
Tenho um slidemenu - Primefaces onde vejo isso por perfil, so que tem um perfil que é o perfil de administrador, ou seja, esse perfil so vai ter os cadastros para mostrar no menu, mais nada, o que está acontecendo é que o tamanho dos sub-itens para apresentar fica exatamente o tamanho do item principal, ou seja, se lá tiver um unico item principal, o tamanho para apresentar os sub-itens vai ser de um a um.
Segue link da imagem para entender melhor:
http://www.sendspace.com/file/wdnii7
Meu codigo xhtml:
<p:slideMenu backLabel="Voltar" trigger="dynaButton" my="left top" at="bottom" style="width:180px; height: 600px;" id="menugeral" model="#{validaTipoTela.MenuBean(telaLogin.perfilUsuario, telaLogin.emailUsuario, telaLogin.idUsuario,telaLogin.idSetor)}"/>
Meu codigo que estou testando para criaçao dinamica do menu:
public MenuModel MenuBean(String _perfilUsuario, String _email, Integer _idUsuario, Integer _idSetor) {
try {
emailLogado = _email;
/*String sSQL = "select hm.id, case when htc.descricao is null then hm.descricao else htc.descricao end as desc_menu, hm.tipo, hm.url, hm.icone "
+ "from help_menu hm "
+ "left join help_tipos_chamados htc on htc.id = hm.id_tipos_chamados "
+ "where case when '" + _perfilUsuario.toString() + "' = 'Usuário' then hm.tipo_menu in ('U','T') else hm.tipo_menu in ('A','T') end "
+ "and case when hm.id_setor = " + _idSetor.toString()
+ "order by hm.ordem";
*/
String sSQL = "select hm.id, case when htc.descricao is null then hm.descricao else htc.descricao end as desc_menu, hm.tipo, hm.url, hm.icone, hm.ordem "
+ "from help_menu hm "
+ "left join help_tipos_chamados htc on htc.id = hm.id_tipos_chamados "
+ "where case when '" + _perfilUsuario.toString() + "' = 'Usuário' then hm.tipo_menu in ('U','T') "
+ " when '" + _perfilUsuario.toString() + "' = 'Suporte' then hm.tipo_menu in ('S','T') "
+ " when '" + _perfilUsuario.toString() + "' = 'Administrador' then hm.tipo_menu in ('A') "
+ " end "
+ "and hm.id_setor is null "
+ "union all "
+ "select hm.id, case when htc.descricao is null then hm.descricao else htc.descricao end as desc_menu, hm.tipo, hm.url, hm.icone, hm.ordem "
+ "from help_menu hm "
+ "left join help_tipos_chamados htc on htc.id = hm.id_tipos_chamados "
+ "where case when '" + _perfilUsuario.toString() + "' = 'Usuário' then hm.tipo_menu in ('U','T') "
+ " when '" + _perfilUsuario.toString() + "' = 'Suporte' then hm.tipo_menu in ('S','T') "
+ " when '" + _perfilUsuario.toString() + "' = 'Administrador' then hm.tipo_menu in ('A') "
+ " end "
+ "and hm.id_setor = " + _idSetor.toString()
+ "order by ordem ";
rs = Conexao.Consulta(sSQL);
} catch (SQLException ex) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Erro ao Carregar Menu", ex.getMessage()));
return null;
}
FacesContext fctx = FacesContext.getCurrentInstance();
ELContext elctx = fctx.getELContext();
Application app = fctx.getApplication();
ExpressionFactory exprFactory = app.getExpressionFactory();
Submenu submenu = null;
model = new DefaultMenuModel();
boolean add;
try {
while (rs.next()) {
if (rs.getInt("tipo") == 0) {
submenu = new Submenu();
submenu.setLabel(rs.getString("desc_menu"));
model.addSubmenu(submenu);
} else if (rs.getInt("tipo") == 1) {
MenuItem item = new MenuItem();
item.setValue(rs.getString("desc_menu"));
if (!rs.getString("url").substring(0, 3).equals("ftp")) {
item.setActionExpression(exprFactory.createMethodExpression(elctx,
"#{validaTipoTela.tipoTela(" + rs.getString("id") + "," + _idUsuario.toString() + "," + _idSetor.toString() + ")}", String.class,
new Class<?>[0]));
} else {
item.setUrl(rs.getString("url"));
item.setTarget("_blank");
}
item.setId("im" + rs.getString("id"));
item.setAjax(false);
item.setIcon(rs.getString("icone"));
item.setUpdate("fdiv");
add = submenu.getChildren().add(item);
if (add) {
model.addSubmenu(submenu);
}
}
}
} catch (SQLException ex) {
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_FATAL, "Erro ao Carregar Menu - Next", ex.getMessage()));
}
return model;
}
Se alguem puder me ajudar!!
Obrigado