How to get the Handle of any UI component without binding?
public String callAction() {
UIComponent component = findComponentInRoot("it1"); //it1 is the Id of the UI
System.out.println(component.getId());
component.setRendered(false);
return null;
}
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 = (UIComponent) kids.next();
if (id.equals(kid.getId())) {
result = kid;
break;
}
result = findComponent(kid, id);
if (result != null) {
break;
}
}
return result;
}
Showing posts with label JSF. Show all posts
Showing posts with label JSF. Show all posts
Tuesday, October 1, 2013
Tuesday, March 19, 2013
ADF 11G : How to Close a popup using JavaScript ?
ADF 11G : How to Close a popup using JavaScript ?
hh



hh
JSF : How to Add Javascript from Bean in JSF ?
JSF : How to Add Javascript from Bean in JSF ?


public String callJS() {
FacesContext facesContext = FacesContext.getCurrentInstance();
org.apache.myfaces.trinidad.render.ExtendedRenderKitService service =
org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
service.addScript(facesContext, "alert('Hi');window.close();");
return null;
}
public String callJS() {
FacesContext facesContext = FacesContext.getCurrentInstance();
org.apache.myfaces.trinidad.render.ExtendedRenderKitService service =
org.apache.myfaces.trinidad.util.Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
service.addScript(facesContext, "alert('Hi');window.close();");
return null;
}
JSF : How to Focus on MouseOver using JS ?
JSF : How to Focus on MouseOver using JS ?

When the user hovers the input text, the field Name gets focus.

When the user hovers the input text, the field Name gets focus.