Wednesday, July 18, 2012

AutoSuggest For InputTextField

AutoSuggest is a very good feature in terms of LOV Below are the step to create AutoSuggest 1)Create a ViewObject (EmployeesVO) 2)For Department Attribute Define List Of Values - Note below items when you define this - You will have to define VO on Read Only access through SQL Query (You need this becasue in this query you need to have an attribute to hold department name for autosuggest to pull this value you need to create a query like below and make sure in Viewobject for each attribute you set the updateable property to Always) SELECT Emp.FirstName, Emp.LastName, Emp.DeptId, (SELECT Dept.DeptName FROM Department Dept WHERE Dept.DeptId = Emp.DeptId) DeptName FROM Employees Emp You autoSuggest will work on this attribute. 3)Define default viewobject for Departments table, this will be the lov for the attribute DeptNm in Employees. 4) In EmployeesVO select attribute DeptName and define lov, make sure when you select DepartmentVO in list datasource in your return value you should have two values something like ViewAttribute ListAttribute DeptName DepartmentName DeptId DepartmentId What will happen is when ever you whill select department name using autosuggest the corresponding value for deptid will be copied to DeptId column in EmployeeVO. 5) In UI Hints select InputText with List Of Values and diplay attribute set to Department Name 5) Now on you JSF page drag and drop EmployeesVO as table for the DepartmentName attribute copy below line before the closing column tag af:autoSuggestBehavior suggestedItems="#{row.bindings.DeptName.suggestedItems}"/ No need to add any list in page definition it will automatically pick up from the LOV defined in the viewobject.

Create New Rows

The best way to create new rows is in pagedefinition define oprataion createInsert or createWithParm for viewobject and execute this operation programmatically. This can even be used when we have to create n number of rows. If you use viewobject.createRow() this will take lot of time to load. Sample code is: op = dbc.getOperationBinding("Createwithparameters"); for(int i=1; i<=15;i++){ op.getParamsMap().put("parm1", value1); op.getParamsMap().put("parm2",value2); op.execute(); if(!op.getErrors().isEmpty()){ bhcLogger.severe("Error in Initializing"); } }

Friday, July 6, 2012

LOV View Accessors from Viewobject View Criteria

ViewAccessors are nothing but the List of values that you can assign to the arrtibutes of view object. In this post we are looking into defining an accessor created based on view criteria of a view object to its attribute. 1) You have defined a view object say deptvo. In this vo you have defined a viewcriteria say deptvc_10_50 (only depts between 10 to 50) 2) Now say you want to create another view object and in its dept dropdown it should only display the values from the above view criteria i.e. dept 10 - 50 only. 3) Create second viewobject say emp_in_dept10_50VO goto attribute deptno attribute on List Of Values region click the + sign this will open the create list of values panel 4)In this click the green + sign and select the viewobject that you have defined in step 1. Now once you have shuttled this viewobject on the right you need to click the Edit button on this window (View Accessors window) and select the viewcriteria to be associated with this lov.