What exactly is #{component} in EL?

The #{component} is an implicit EL variable referring the current UIComponent in EL scope (see also implicit EL objects). You can usually only refer it in component’s HTML attribute or in template text children. E.g. in case of <h:inputText> it will reference an instance of UIInput class which has among others an isValid() method. <h:inputText … Read more

How to pass custom component parameters in java and xml

(Full disclosure: This question is an offshoot of Creating custom view) You can create constructors beyond the three standard ones inherited from View that add the attributes you want… MyComponent(Context context, String foo) { super(context); // Do something with foo } …but I don’t recommend it. It’s better to follow the same convention as other … Read more

Find component by ID in JSF

You can use the following code: public UIComponent findComponent(final String id) { FacesContext context = FacesContext.getCurrentInstance(); UIViewRoot root = context.getViewRoot(); final UIComponent[] found = new UIComponent[1]; root.visitTree(new FullVisitContext(context), new VisitCallback() { @Override public VisitResult visit(VisitContext context, UIComponent component) { if (component != null && id.equals(component.getId())) { found[0] = component; return VisitResult.COMPLETE; } return VisitResult.ACCEPT; } … Read more