سؤال

I am trying to set focus to a component in Icefaces 1.8.2, but it doesn't work probably because of the component not being rendered at the time of the method call. Any ideas?

JavascriptContext.addJavascriptCall(getContext(),
                "document.getElementById('"+ getClientId(component) + "').focus();");
هل كانت مفيدة؟

المحلول

This works, I messed it up somewhere previously..

JavascriptContext.applicationFocus(getContext(), getClientId(component));


public static String getClientId(UIComponent component) {
    return component.getClientId(getContext());
}

public static FacesContext getContext() {
    return FacesContext.getCurrentInstance();
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top