Skip to content

Instantly share code, notes, and snippets.

Created October 14, 2011 03:01
Show Gist options
  • Save steppat/1286144 to your computer and use it in GitHub Desktop.
Save steppat/1286144 to your computer and use it in GitHub Desktop.
filro para imprimir as IDs do component tree (Mojarra)
import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Set;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
public class SessionAttributeLogger implements Filter {
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
chain.doFilter(request, response);
HttpSession session = ((HttpServletRequest) request).getSession();
Enumeration<String> names = session.getAttributeNames();
while (names.hasMoreElements()) {
String name = names.nextElement();
Object attribute = session.getAttribute(name);
if (attribute instanceof HashMap) {
System.out.println("------ IDS DA ARVORE -------");
HashMap<String, Object> originalViews = (HashMap<String, Object>) attribute;
HashMap<String, Object> views = new LinkedHashMap<String, Object>(originalViews);
Set<String> keySet = views.keySet();
int i = 0;
for (String key : keySet) {
System.out.printf("%d ID: %s %n", ++i , key);
System.out.println("------ FIM IDS -------");
System.out.println("OUTROS ATTRIBUTOS DA SESSAO: " + name);
public void destroy() {
public void init(FilterConfig arg0) throws ServletException {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment