Wednesday, February 15, 2012

Map Example

package view;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MapExample {

public static void main(String[] args) {

Map mp=new HashMap();

// adding or set elements in Map by put method key and value pair
mp.put(new Integer(2), "Two");
mp.put(new Integer(1), "One");
mp.put(new Integer(3), "Three");
mp.put(new Integer(4), "Four");

//Get Map in Set interface to get key and value
Set s=mp.entrySet();

//Move next key and value of Map by iterator
Iterator it=s.iterator();

while(it.hasNext())
{
// key=value separator this by Map.Entry to get key and value
Map.Entry m =(Map.Entry)it.next();

// getKey is used to get key of Map
int key=(Integer)m.getKey();

// getValue is used to get value of key in Map
String value=(String)m.getValue();

System.out.println("Key :"+key+" Value :"+value);
}
System.out.println("Check Value: "+mp.containsValue("One"));
System.out.println("Check Key: "+mp.containsKey(1));

}
}

Tuesday, February 7, 2012

Search Criteria - View Criteria

Create view criterias against a view object (you can also have lov in the view criteria fields i.e. by defining the attribute as selectively required, as in screeshot).

In your datacontrol panel inside named criteria

, you will see this viewcriteria drag and drop it as ADF Query panel with table.

Monday, January 23, 2012

Key Sample: How to find row from viewobject based on key attribute

DCBindingContainer dbc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iter = dbc.findIteratorBinding("EmployeeIterator");
Key k1 = new Key(new Object[]{100}); //employee id
Row[] r1 = iter.getViewObject().findByKey(k1, 1);
for(Row r: r1){
System.out.println(r.getAttribute(0)+" "+r.getAttribute(1));
}

TaskFlow as Popup Window

TaskFlow in Popup

You can run a taskflow like a popup window and also return value:
Two things to be taken care of 1) Create a bounded task flow (one which will be displayed in popup). In properties window for this taskflow, in behaviour tab set run as Dialog property to true and display type as inline popup. 2) The button, on click of which this should appear as popup. Select the button and in property window set below properties: - Use window : true - Window Height: 300 - Window Width:300 You can also set parameters as under. 1)In 1st taskflow definition drag and drop the taskflow which you want to run like a popup window
2) select that taskflow and in properties panel in return parameter you can specify a parameter, if you plan to return something
- In behaviour tab set Run as Dialog property to True & display type default(external window)

and then you can set pageflow scope varible to return value from here for selected record.
AdfFacesContext.getCurrentInstance().getPageFlowScope().put("parameter", value);

AutoSuggest TextField (InputText Field).


AutoSuggest Behaviour on Text Fields

1) In ViewObjext definition create a new attribute (transient attribute, because autosuggest will work on the description / id lov for e.g. if you define the lov on any id field and you are displaying description / name as label then in that case the sorting will happen on ids and not on descripti

on).
To avoid this problem define transient attribute, name it accordingly and in lov Configuration Select that id attribute (employee id) as well as description, so what will happen is based on the description selected corresponding id will also be selected).

In UI Hints you can select the name/descirption field to display and List Type should be InputText with List of Values.

2) Now on you JSF page, lets say that you have dragged and dropped this viewobjects datacontrol as table and for this field you select it as textfild(default will be combo etc).
Add this code for you field

e.g.




Once you drag and drop view as table then the tree node is created in table and this expressions will work.

findRowByIteratorAttribute - Find a row within Iterator with some attribute value

Once we get hold of iterator and when we need to find a row in iterator based on any attribute value, we can use below code

String lName = "Joe";
DCBindingContainer dbc = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
DCIteratorBinding iter = dbc.findIteratorBinding("EmployeesIterator");
RowIterator rIter= iter.findRowsByAttributeValue("LastName", true, lName);
String empId = rIter.first().getAttribute("AcctId").toString();

Sunday, January 22, 2012

Setting PageFlowScope Parameters from Button ActionListener withoout code

1) When we want to set pageflowscope parameters without writing code

- Attach SetActionListener Operation to button




The EmployeeId is defined against employee id attribute against employee iterator on pagedefinition.

We can have n number of the variables defined here to pass pageflow scope variables.