LOV Fields are: fnameId and lnameId
Button: Clear
Create Managed Bean and write the following code:
public void showLOVValues()
{
FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
ComponentReference<RichInputListOfValues>
richText1 = ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("fnameId"));
RichInputListOfValues FinputText1 = richText1.getComponent();
ComponentReference<RichInputListOfValues> richText2 =
ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("lnameId"));
RichInputListOfValues LinputText2 = richText2.getComponent();
System.out.println("**** First LOV String is :"+FinputText1.getValue());
System.out.println("**** Second LOV String is :"+LinputText2.getValue());
}
Properties:
AutoSubmit = True
PartialTrigger = ClearButton for both Lov fields
=============================================================
public String Findbutton_action() {
System.out.println("**** Find Button ****");
System.out.println("GroupCode is :"+getGroupCodeBind().getValue());
System.out.println("GroupName is :"+getGroupNameBind().getValue());
/* FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
ComponentReference<RichInputListOfValues>
richText1 = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupCodeId"));
RichInputListOfValues GroupCodeStr = richText1.getComponent();
ComponentReference<RichInputListOfValues>
richText2 = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupNameId"));
RichInputListOfValues GroupNameStr = richText2.getComponent();
RichInputListOfValues GroupCodeStr1 = (RichInputListOfValues) root.findComponent("groupCodeId");
//ComponentReference<RichInputListOfValues> richText2 =
//ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("groupNameId"));
System.out.println("**** First LOV String is :"+GroupCodeStr.getValue());
System.out.println("**** Second LOV String is :"+GroupNameStr.getValue());
//System.out.println("**** GroupCodeStr1 LOV String is :"+GroupCodeStr1.getValue().toString());
*/
return null;
}
public String clearButton_action() {
System.out.println("**** Clear Button ****");
AppModuleAMImpl am = (AppModuleAMImpl) resolvElDC("AppModuleAMDataControl");
ViewObject grpSearchVo = am.getGroupSearch1();
grpSearchVo.executeEmptyRowSet();
Row row=grpSearchVo.createRow();
grpSearchVo.insertRow(row);
grpSearchVo.setCurrentRow(row);
/* FacesContext facesContext = FacesContext.getCurrentInstance();
UIViewRoot root = facesContext.getViewRoot();
ComponentReference<RichInputListOfValues>
richText1 = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupCodeId"));
RichInputListOfValues GroupCodeStr = richText1.getComponent();
ComponentReference<RichInputListOfValues>
richText2 = ComponentReference.newUIComponentReference((RichInputListOfValues)findComponent("groupNameId"));
RichInputListOfValues GroupNameStr = richText2.getComponent();
//ComponentReference<RichInputListOfValues> richText2 =
//ComponentReference.newUIComponentReference((RichInputListOfValues)root.findComponent("groupNameId"));
GroupCodeStr.setValue("");
GroupNameStr.setValue("");
System.out.println("**** First LOV String is :"+GroupCodeStr.getValue());
System.out.println("**** Second LOV String is :"+GroupNameStr.getValue());
*/
return null;
}
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.getId().equals(id)){
found[0] = component;
return VisitResult.COMPLETE;
}
return VisitResult.ACCEPT;
}
});
return found[0];
}
public Object resolvElDC(String data) {
FacesContext fc = FacesContext.getCurrentInstance();
Application app = fc.getApplication();
ExpressionFactory elFactory = app.getExpressionFactory();
ELContext elContext = fc.getELContext();
ValueExpression valueExp =
elFactory.createValueExpression(elContext, "#{data." + data + ".dataProvider}", Object.class);
return valueExp.getValue(elContext);
}