Hi all, How to implement public void reset(QueryDescriptor qd) { }, Actually i have created a af:inputListOfValues programmatically, in that by default it has Reset button , but that functionality is not implemented , How can i implement it
- <span><span>
- package view.lov;
-
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
-
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Date;
- import java.util.HashMap;
- import java.util.Iterator;
- import java.util.List;
-
- import java.util.Map;
- import java.util.Set;
-
- import javax.faces.application.FacesMessage;
- import javax.faces.component.UIComponent;
- import javax.faces.context.FacesContext;
- import javax.faces.validator.ValidatorException;
-
- import oracle.adf.view.rich.model.AttributeCriterion;
- import oracle.adf.view.rich.model.AttributeDescriptor;
- import oracle.adf.view.rich.model.ColumnDescriptor;
- import oracle.adf.view.rich.model.ConjunctionCriterion;
- import oracle.adf.view.rich.model.Criterion;
- import oracle.adf.view.rich.model.ListOfValuesModel;
- import oracle.adf.view.rich.model.QueryDescriptor;
- import oracle.adf.view.rich.model.QueryModel;
- import oracle.adf.view.rich.model.TableModel;
-
- import org.apache.myfaces.trinidad.model.CollectionModel;
- import org.apache.myfaces.trinidad.model.RowKeySet;
- import org.apache.myfaces.trinidad.model.RowKeySetImpl;
-
-
- public class ListOfValuesModelImpl extends ListOfValuesModel {
-
- CollectionModel baseModel = new BaseLovCollection();
-
- CollectionModel listModel = new ListLovCollection();
- List _values = new ArrayList();
- List _recentValues = new ArrayList();
- List _recentValues1 = new ArrayList();
- List _filteredList = new ArrayList();
- List<LOVItemSelectionListener> _selectionListeners = new ArrayList<LOVItemSelectionListener>();
- List _listenersFilteredList = new ArrayList();
-
- String[] _attrs = new String[] { "ename", "job", "sal" };
-
- List<String> _attributes = new ArrayList<String>();
-
- public ListOfValuesModelImpl() {
- initAttrbiutes();
- initTestData();
- }
-
- private void initAttrbiutes() {
- _attributes.add("ename");
- _attributes.add("empno");
-
- _attributes.add("job");
- _attributes.add("mgr");
- _attributes.add("hireDate");
- _attributes.add("sal");
- _attributes.add("comm");
- _attributes.add("deptno");
- }
-
- private void initTestData() {
-
-
-
- Object[][] _DIR_DATA = DummyDataService.getInst().getEmpData();
- for (int i = 0; i < _DIR_DATA.length * 50; i++) {
- try {
- Object data[] = _DIR_DATA[i % _DIR_DATA.length];
-
- String item1 = (String)data[0] + new Integer(i).toString();
- Integer item2 = new Integer(data[2].toString());
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-mm-dd");
- Date item3 = sdf.parse(data[3].toString());
- Integer item4 = new Integer(data[4].toString());
- Integer item5 = new Integer(data[5].toString());
- Integer item6 = new Integer(data[6].toString());
- String item7 = new Integer(i).toString();
- EmpRowData _curRow =
- new EmpRowData(new Integer(i), item1, (String)data[1], item2, item3, item4, item5, item6, item7);
- _values.add(_curRow);
- } catch (ParseException e) {
- e.printStackTrace();
- }
- }
- _filteredList.addAll(_values);
- }
-
- public void addItemSelectionListener(LOVItemSelectionListener list) {
- _selectionListeners.add(list);
- }
-
- void filterList(String eName, List filtered) {
- filtered.clear();
- if (eName != null) {
- for (Object data : _values) {
- if (((EmpRowData)data).getEname().startsWith(eName)) {
- filtered.add(data);
- }
- }
- }
- if (filtered.size() == 0) {
- filtered.addAll(_values);
- }
- }
-
-
- @Override
- public List<? extends Object> getItems() {
- return getValues();
- }
-
-
- @Override
- public QueryModel getQueryModel() {
- return new QueryModelImpl();
- }
-
-
- @Override
- public List<? extends Object> getRecentItems() {
- return getRecentValues();
- }
-
- @Override
- public TableModel getTableModel() {
- return new TableModelImpl(getListModel());
- }
-
- public CollectionModel getListModel() {
- return listModel;
- }
-
- @Override
- public List<ColumnDescriptor> getItemDescriptors() {
- List<ColumnDescriptor> descriptors = getTableModel().getColumnDescriptors();
- if (descriptors != null && descriptors.size() > 3) {
- return descriptors.subList(0, 3);
- }
- return descriptors;
- }
-
- @Override
- public boolean isAutoCompleteEnabled() {
- return false;
- }
-
- public void performQuery(QueryDescriptor qd) {
- AttributeCriterion criterion = (AttributeCriterion)qd.getConjunctionCriterion().getCriterionList().get(0);
- String ename = (String)criterion.getValues().get(0);
- filterList(ename, _filteredList);
- }
-
- public List<Object> autoCompleteValue(Object value) {
-
- filterList((String)value, _filteredList);
- if (_filteredList.size() == 1) {
- List<Object> returnList = new ArrayList<Object>();
- EmpRowData rowData = (EmpRowData)_filteredList.get(0);
- Object rowKey = rowData.getRowId();
- RowKeySet rowKeySet = new RowKeySetImpl();
- rowKeySet.add(rowKey);
- returnList.add(rowKeySet);
- return returnList;
- }
- return null;
- }
-
- public void valueSelected(Object value) {
- EmpRowData rowData = _getRowData(value);
- if (rowData != null) {
- _addToRecentValuesList(rowData, _recentValues);
- }
- Iterator<LOVItemSelectionListener> iter = _selectionListeners.iterator();
- while (iter.hasNext()) {
- LOVItemSelectionListener lit = iter.next();
- lit.valueSelected(rowData);
- }
- }
-
- private void _addToRecentValuesList(EmpRowData rowData, List recentValues) {
- if (!recentValues.contains(rowData))
- recentValues.add(0, rowData);
-
- int size = recentValues.size();
- if (size > 3)
- recentValues.remove(3);
- }
-
- private EmpRowData _getRowData(Object selectedRow) {
- if (selectedRow != null && selectedRow instanceof List) {
- List listvalue = (List)selectedRow;
- for (int i = 0; i < listvalue.size(); i++) {
- Object rowData = listvalue.get(i);
- if (rowData instanceof EmpRowData) {
- return ((EmpRowData)rowData);
- }
- }
- } else if (selectedRow != null && selectedRow instanceof RowKeySet) {
- Iterator selection = ((RowKeySet)selectedRow).iterator();
- while (selection.hasNext()) {
- Object rowKey = selection.next();
- Object oldRowKey = listModel.getRowKey();
- listModel.setRowKey(rowKey);
- EmpRowData rowData = (EmpRowData)listModel.getRowData();
- listModel.setRowKey(oldRowKey);
- return rowData;
- }
- }
- return null;
- }
-
- public void validate(FacesContext facesContext, UIComponent uIComponent, Object object) {
- for (Object data : _values) {
- if (((EmpRowData)data).getEname().equals(object)) {
- return;
- }
- }
- FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Not a Valid Value", "Not a Valid Value");
- throw new ValidatorException(message);
- }
-
- public List getValues() {
- return _values;
- }
-
- public List getRecentValues() {
- List recentValues = new ArrayList();
- recentValues.addAll(_recentValues);
-
- if (recentValues.size() > 0)
- recentValues.add(new EmpRowData(null, null, null, null, null, null, null, null, null));
-
- return recentValues;
- }
-
- @Override
- public Object getValueFromSelection(Object selectedRow) {
- EmpRowData rowData = _getRowData(selectedRow);
- if (rowData != null) {
- return rowData.getEname();
- }
- return null;
- }
-
-
- public QueryDescriptor getQueryDescriptor() {
- if (_queryDescriptor == null)
- _queryDescriptor = new QueryDescriptorImpl();
- return _queryDescriptor;
- }
-
- private QueryDescriptor _queryDescriptor;
- private DemoComboboxLOVBean _bean;
-
-
- class BaseLovCollection extends CollectionModel {
- public Object getRowKey() {
- if (_row != null) {
- return _row.getRowId();
- }
- return null;
- }
-
-
- public void setRowKey(Object rowKey) {
- if (rowKey == null) {
- _row = null;
- return;
- }
-
- int index = -1;
- for (int i = 0; i < _filteredList.size(); i++) {
- String rowId = ((EmpRowData)_filteredList.get(i)).getRowId();
- if (rowId.equals(rowKey)) {
- index = i;
- break;
- }
- }
-
- setRowIndex(index);
- }
-
- public void setRowIndex(int rowIndex) {
- int size = _filteredList.size();
- if (rowIndex < 0 || rowIndex > size || size == 0) {
- _row = null;
- _rowIndex = -1;
- } else {
- _row = (EmpRowData)_filteredList.get(rowIndex);
- _rowIndex = rowIndex;
- }
- }
-
- public int getRowIndex() {
- return _rowIndex;
- }
-
- public Object getRowData() {
- return _row;
- }
-
- public int getRowCount() {
- return _filteredList.size();
- }
-
- public boolean isRowAvailable() {
- return (_row != null);
- }
-
- public Object getRowData(int rowIndex) {
- int oldIndex = getRowIndex();
- try {
- setRowIndex(rowIndex);
- return getRowData();
- } finally {
- setRowIndex(oldIndex);
- }
- }
-
- public boolean isSortable(String property) {
- return false;
- }
-
- public List getSortCriteria() {
- return Collections.EMPTY_LIST;
- }
-
- public Object getWrappedData() {
- return BaseLovCollection.this;
- }
-
- public void setWrappedData(Object data) {
- throw new UnsupportedOperationException();
- }
-
- public BaseLovCollection() {
- }
-
- EmpRowData _row = null;
- int _rowIndex = -1;
- }
-
- class ListLovCollection extends CollectionModel {
- public Object getRowKey() {
- if (_row != null) {
- return _row.getRowId();
- }
- return null;
- }
-
-
- public void setRowKey(Object rowKey) {
- if (rowKey == null) {
- _row = null;
- return;
- }
-
- int index = -1;
- for (int i = 0; i < _filteredList.size(); i++) {
- String rowId = ((EmpRowData)_filteredList.get(i)).getRowId();
- if (rowId.equals(rowKey)) {
- index = i;
- break;
- }
- }
-
- setRowIndex(index);
- }
-
- public void setRowIndex(int rowIndex) {
- int size = _filteredList.size();
- if (rowIndex < 0 || rowIndex > size || size == 0) {
- _row = null;
- _rowIndex = -1;
- } else {
- _row = (EmpRowData)_filteredList.get(rowIndex);
- _rowIndex = rowIndex;
- }
- }
-
- public int getRowIndex() {
- return _rowIndex;
- }
-
- public Object getRowData() {
- return _row;
- }
-
- public int getRowCount() {
- return _filteredList.size();
- }
-
- public boolean isRowAvailable() {
- return (_row != null);
- }
-
- public Object getRowData(int rowIndex) {
- int oldIndex = getRowIndex();
- try {
- setRowIndex(rowIndex);
- return getRowData();
- } finally {
- setRowIndex(oldIndex);
- }
- }
-
- public boolean isSortable(String property) {
- return false;
- }
-
- public List getSortCriteria() {
- return Collections.EMPTY_LIST;
- }
-
- public Object getWrappedData() {
- return ListLovCollection.this;
- }
-
- public void setWrappedData(Object data) {
- throw new UnsupportedOperationException();
- }
-
- EmpRowData _row = null;
- int _rowIndex = -1;
- }
-
-
-
-
-
-
-
-
- public static class QueryModelImpl extends QueryModel {
-
- public QueryDescriptor create(String name, QueryDescriptor qdBase) {
- return null;
- }
-
- public void delete(QueryDescriptor qd) {
- }
-
- public List<AttributeDescriptor> getAttributes() {
- return null;
- }
-
- public List<QueryDescriptor> getSystemQueries() {
- return null;
- }
-
- public List<QueryDescriptor> getUserQueries() {
- return null;
- }
-
- public void reset(QueryDescriptor qd) {
- }
-
- public void setCurrentDescriptor(QueryDescriptor qd) {
- }
-
- public void update(QueryDescriptor qd, Map<String, Object> uiHints) {
- }
- }
-
-
-
-
- public static class QueryDescriptorImpl extends QueryDescriptor {
- public QueryDescriptorImpl() {
- _conjCriterion = new ConjunctionCriterionImpl();
- }
-
- public void addCriterion(String name) {
- }
-
- public void changeMode(QueryDescriptor.QueryMode mode) {
- }
-
- public ConjunctionCriterion getConjunctionCriterion() {
- return _conjCriterion;
- }
-
- public void setConjunctionCriterion(ConjunctionCriterion criterion) {
- _conjCriterion = criterion;
- }
-
- public String getName() {
- return null;
- }
-
- public Map<String, Object> getUIHints() {
- return new HashMap<String, Object>();
- }
-
- public void removeCriterion(oracle.adf.view.rich.model.Criterion object) {
- }
-
- public AttributeCriterion getCurrentCriterion() {
- return null;
- }
-
- public void setCurrentCriterion(AttributeCriterion attrCriterion) {
- }
-
- ConjunctionCriterion _conjCriterion;
- }
-
- public static class AttributeDescriptorImpl extends AttributeDescriptor {
-
- public AttributeDescriptor.ComponentType getComponentType() {
- return AttributeDescriptor.ComponentType.inputText;
- }
-
- public String getDescription() {
- return null;
- }
-
- public String getFormat() {
- return null;
- }
-
- public String getLabel() {
- return "Ename";
- }
-
- public int getLength() {
- return 0;
- }
-
- public int getMaximumLength() {
- return 0;
- }
-
- public Object getModel() {
- return null;
- }
-
- public String getName() {
- return null;
- }
-
- public Set<AttributeDescriptor.Operator> getSupportedOperators() {
- return null;
- }
-
- public Class getType() {
- return null;
- }
-
- public boolean isReadOnly() {
- return false;
- }
-
- public boolean isRequired() {
- return false;
- }
- }
-
- public static class ConjunctionCriterionImpl extends ConjunctionCriterion {
- public ConjunctionCriterionImpl() {
- _criterionList = new ArrayList<Criterion>();
- _criterionList.add(new AttributeCriterionImpl());
- }
-
- public ConjunctionCriterion.Conjunction getConjunction() {
- return ConjunctionCriterion.Conjunction.NONE;
- }
-
- public List<oracle.adf.view.rich.model.Criterion> getCriterionList() {
- return _criterionList;
- }
-
- public Object getKey(oracle.adf.view.rich.model.Criterion criterion) {
- return Integer.toString(0);
- }
-
- public Criterion getCriterion(Object key) {
- assert (_criterionList != null);
- return _criterionList.get(0);
- }
-
- public void setConjunction(ConjunctionCriterion.Conjunction conjunction) {
- }
- List<Criterion> _criterionList;
- }
-
- public static class AttributeCriterionImpl extends AttributeCriterion {
- public AttributeCriterionImpl() {
- if (_values == null) {
- _values = new ArrayList<Object>();
- _values.add("A");
- }
- }
-
- public AttributeDescriptor getAttribute() {
- return new AttributeDescriptorImpl();
- }
-
- public AttributeDescriptor.Operator getOperator() {
- return null;
- }
-
- public Map<String, AttributeDescriptor.Operator> getOperators() {
- return null;
- }
-
- public List<? extends Object> getValues() {
- return _values;
- }
-
- public boolean isRemovable() {
- return false;
- }
-
- public void setOperator(AttributeDescriptor.Operator operator) {
- }
-
- List<Object> _values;
- }
-
- public class TableModelImpl extends TableModel {
- public TableModelImpl(CollectionModel collectionModel) {
- assert (collectionModel != null);
- _collectionModel = collectionModel;
- }
-
- @Override
- public CollectionModel getCollectionModel() {
- return _collectionModel;
- }
-
- @Override
- public List<ColumnDescriptor> getColumnDescriptors() {
- if (_descriptors == null) {
- _descriptors = new ArrayList<ColumnDescriptor>(_attributes.size());
- for (String attr : _attributes) {
- _descriptors.add(new ColumnDescriptorImpl(attr));
- }
- }
- return _descriptors;
- }
-
- public class ColumnDescriptorImpl extends ColumnDescriptor {
- public ColumnDescriptorImpl(String name) {
- _name = name;
- }
-
- @Override
- public String getFormat() {
- return null;
- }
-
- @Override
- public String getLabel() {
- return _name.toUpperCase();
- }
-
- @Override
- public String getName() {
- return _name;
- }
-
- @Override
- public Class getType() {
- return String.class;
- }
-
- @Override
- public String getAlign() {
- return null;
- }
-
- @Override
- public AttributeDescriptor.ComponentType getComponentType() {
- return AttributeDescriptor.ComponentType.inputText;
- }
-
- @Override
- public String getDescription() {
- return null;
- }
-
- @Override
- public Set<AttributeDescriptor.Operator> getSupportedOperators() {
- return Collections.emptySet();
- }
-
- @Override
- public int getLength() {
- return 0;
- }
-
- public int getMaximumLength() {
- return 0;
- }
-
- public Object getModel() {
- return null;
- }
-
- @Override
- public int getWidth() {
- if (_name.equalsIgnoreCase("ename"))
- return 12 * 7 + 3;
- else if (_name.equalsIgnoreCase("empno"))
- return 3 * 7 + 3;
- else if (_name.equalsIgnoreCase("job"))
- return 10 * 7 + 3;
- else if (_name.equals("mgr"))
- return 2 * 7 + 3;
- return 0;
- }
-
-
- @Override
- public boolean isReadOnly() {
- return true;
- }
-
- @Override
- public boolean isRequired() {
- return false;
- }
-
- private String _name;
-
- }
-
-
- private CollectionModel _collectionModel;
- private List<ColumnDescriptor> _descriptors;
- }
-
- }
-
- </span></span>
- <af:inputListOfValues label="Ename" id="idInputLOV"
- value="#{demoComboboxLOV.ename}" autoSubmit="true"
- popupTitle="Search and Select: Ename"
- searchDesc="Choose a name"
- model="#{demoComboboxLOV.listOfValuesModel}" />