list html page elements not having id

Icefaces ajax render performances issues could be sequence of dom elements without id. The present post helps to list all elements not having id to be fixed.

Open your page in your browser.
In developer console create following function

function chkid(ch){
  if(ch.id==""){
    console.log(ch.tagName+' : '+ch.id + ' childof ==> ' + ch.up().id)
  }
  ch.childElements().each(
    function(fils){
      chkid(fils)
    }
  );
}

then call chkid with any dom element. To get all, call chkid with body element

$$('body')[0].childElements().each(function(ch){chkid(ch)});

Nota : Here we use prototypejs framework

icefaces and SendUpdates optimization

if you encounter slow rendering (on icefaces tree for example) and generally when you code using icefaces framework, be sure that any html component you write has an id or has an icefaces component as parent.
In fact, icefaces client module send ajax request to the icefaces server module in aim to retrieve DOM changes. icefaces server module try to look for dom changes, and when each element has changed but have no id, it looks for its parent in the dom and insert all children of this parent as changed.

In my case i have a page with two elements: a <div>…</div> and just after an <ice:tree>…</ice:tree>
Unfortenatly, i don’t put an id to my <div>. So when i expand one node in the <ice:tree> i got all tree nodes sent as updates elements in the icefaces ajax response.
setting an id or converting your <div> to <ice:panelGroup> fix problem.

@see
– method computing and sending updates: com.icesoft.faces.context.PushModeSerializer -> serialize(final Document document)
– to debug dom updates, add following in your web.xml:

    
        com.icesoft.faces.debugDOMUpdate
        true
    

icefaces : refresh whole page with code

     public void refreshPage() {
        FacesContext context = FacesContext.getCurrentInstance();
        Application application = context.getApplication();
        ViewHandler viewHandler = application.getViewHandler();
        UIViewRoot viewRoot = viewHandler.createView(context, context.getViewRoot().getViewId());
        context.setViewRoot(viewRoot);
    }

icefaces : force refresh a portion of page

    public void refreshUI(String componentId) {
        UIComponent uiComp = BaseBean.findComponentInRoot(componentId);
        if (uiComp != null) {
            uiComp.getChildren().clear();
        }
    }

    public static UIComponent findComponentInRoot(String id) {
        UIComponent component = null;

        FacesContext facesContext = FacesContext.getCurrentInstance();
        if (facesContext != null) {
            UIComponent root = facesContext.getViewRoot();
            component = findComponent(root, id);
        }

        return component;
    }

    public static UIComponent findComponent(UIComponent base, String id) {
        if (id.equals(base.getId())) {
            return base;
        }

        UIComponent kid = null;
        UIComponent result = null;
        Iterator kids = base.getFacetsAndChildren();
        while (kids.hasNext() && (result == null)) {
            kid = kids.next();
            if (id.equals(kid.getId())) {
                result = kid;
                break;
            }
            result = findComponent(kid, id);
            if (result != null) {
                break;
            }
        }
        return result;
    }