In the new patchset for panel collection they have introduced extended values for featureoff.
Will try to put a sample for the above features off.
Sunday, January 16, 2011
Jdeveloper 11.1.1.4 af Query New Properties Label and access keys
In this new patch they have included provision to give label and access keys to af query component see the below image.
Saturday, January 15, 2011
Jdeveloper 11.1.1.4 Exact Match LOV
Checked the source for Exact match, Small change needs to be done.
In the new IDE if we try to use interal api it gives error.
But in the runtime it doesn't give error. But for pre-cautionary sake changed the logic for getting the ViewCriteria for setting the value.
Changed the FacesControlLOVBinding.ListOfValuesModelImpl to oracle.adf.view.rich.model.ListOfValuesModel which is not internal api. and for getting the ViewCriteria for the current LOV changed the code like in the below screenshot.
New Code And the Source which will run in Jdev 11.1.1.4 is below
Download: Latest Source For Exact Match LOV In Jdev 11.1.1.4
In the new IDE if we try to use interal api it gives error.
But in the runtime it doesn't give error. But for pre-cautionary sake changed the logic for getting the ViewCriteria for setting the value.
Changed the FacesControlLOVBinding.ListOfValuesModelImpl to oracle.adf.view.rich.model.ListOfValuesModel which is not internal api. and for getting the ViewCriteria for the current LOV changed the code like in the below screenshot.
New Code And the Source which will run in Jdev 11.1.1.4 is below
Download: Latest Source For Exact Match LOV In Jdev 11.1.1.4
public void lovcustomLaunch(LaunchPopupEvent launchPopupEvent) { String currentColumnName = null; String valueExpression = null; JUCtrlListBinding ctrlListBinding = null; ViewObject baseViewObject = null; AttributeDef lovAttributeDef = null; AttributeDef lovlistAttributeDef = null; ListBindingDef listBindingDef = null; String[] listAttributeNames = null; ListOfValuesModel listOfValuesModel = null; ViewCriteria viewCriteria = null; Object submittedValue = null; ViewCriteriaRow viewCriteriaRow = null; RowSet rowSet = null; Row listRow = null; Row baseViewObjectRow = null; if (!launchPopupEvent.isLaunchPopup()) { return; } submittedValue = launchPopupEvent.getSubmittedValue(); if (submittedValue == null) { return; } BindingContext bindingContext = BindingContext.getCurrent(); BindingContainer bindingContainter = bindingContext.getCurrentBindingsEntry(); RichInputListOfValues inputListOfValues = (RichInputListOfValues)launchPopupEvent.getComponent(); if(inputListOfValues != null) { // below code gets the value expression for the current column i.e in our case #{bindings.DepartmentId.inputValue} valueExpression = inputListOfValues.getValueExpression(inputListOfValues.VALUE_KEY.getName()).toString(); if (valueExpression != null) { // if the column is in the af table then the value will be #{row.bindings.DepartmentId.inputValue} so we are replacing row. valueExpression = StringUtils.replace(valueExpression, "row.", ""); currentColumnName = valueExpression.substring(valueExpression.indexOf(".")+1, valueExpression.lastIndexOf(".")); if (currentColumnName != null) { ctrlListBinding = (JUCtrlListBinding)bindingContainter.getControlBinding(currentColumnName); if (ctrlListBinding != null) { baseViewObject = ctrlListBinding.getIteratorBinding().getViewObject(); if (baseViewObject != null) { baseViewObjectRow = baseViewObject.getCurrentRow(); lovAttributeDef = baseViewObject.findAttributeDef(currentColumnName); if (lovAttributeDef != null) { listBindingDef = lovAttributeDef.getListBindingDef(); if (listBindingDef != null) { listAttributeNames = listBindingDef.getListAttrNames(); if (listAttributeNames != null && listAttributeNames.length > 0) { listOfValuesModel = inputListOfValues.getModel(); if (listOfValuesModel != null) { viewCriteria = ctrlListBinding.getListIterBinding().getViewObject().getViewCriteriaManager().getViewCriteria(listBindingDef.getDisplayCriteriaName()); if (viewCriteria !=null) { viewCriteriaRow = (ViewCriteriaRow)viewCriteria.getRowAtRangeIndex(0); if (viewCriteriaRow != null) { lovlistAttributeDef = viewCriteriaRow.getStructureDef().findAttributeDef(listAttributeNames[0]); if (lovAttributeDef != null) { if (lovAttributeDef.getSQLType() == OracleTypes.NUMBER) { viewCriteriaRow.setAttribute(listAttributeNames[0], submittedValue); viewCriteriaRow.getCriteriaItem(listAttributeNames[0]).setOperator(JboCompOper.OPER_EQ); }else if (lovAttributeDef.getSQLType() == OracleTypes.VARCHAR) { viewCriteriaRow.setAttribute(listAttributeNames[0], submittedValue+"%"); viewCriteriaRow.getCriteriaItem(listAttributeNames[0]).setOperator(JboCompOper.OPER_LIKE); } listOfValuesModel.performQuery(listOfValuesModel.getQueryDescriptor()); if (ctrlListBinding.getListIterBinding().getRowSetIterator() != null && ctrlListBinding.getListIterBinding().getRowSetIterator().getRowCount() > 0) { rowSet = ctrlListBinding.getListIterBinding().getRowSetIterator().getRowSet(); listRow = rowSet.getRowAtRangeIndex(0); if (listRow != null && listRow.getAttribute(listAttributeNames[0]).equals(submittedValue)) { if (baseViewObjectRow != null) { baseViewObjectRow.setAttribute(currentColumnName, submittedValue); } RowKeySetImpl rowKeySet = new RowKeySetImpl(); List list = new ArrayList(); list.add(listRow.getKey()); launchPopupEvent.setLaunchPopup(false); launchPopupEvent.queue(); inputListOfValues.queueEvent(new ReturnPopupEvent(inputListOfValues,rowKeySet)); AdfFacesContext.getCurrentInstance().addPartialTarget(inputListOfValues); } } } } } } } } } } } } } } }
JDeveloper 11.1.1.4 released today
Downloaded JDeveloper 11.1.1.4 and checking my earlier samples what is the changes need to be done.
http://www.oracle.com/technetwork/developer-tools/jdev/downloads/index.html
http://www.oracle.com/technetwork/developer-tools/jdev/relnotes-14-jan-11-261400.html
New Features And Releases :http://www.oracle.com/technetwork/developer-tools/jdev/index-088099.html
http://www.oracle.com/technetwork/developer-tools/jdev/downloads/index.html
http://www.oracle.com/technetwork/developer-tools/jdev/relnotes-14-jan-11-261400.html
New Features And Releases :http://www.oracle.com/technetwork/developer-tools/jdev/index-088099.html
Friday, January 14, 2011
Jdeveloper 11.1.1.3 InputListOfValues new Facet "searchContent" used for Custom LOV
In JDeveloper 11.1.1.3 new facet "searchContent" is introduced in af:InputListOfValues, where you can create your own LOV content whereby you don't need listofvaluesmodel to create the lov. And moreover you don't need to create LOV in the ADF Model.
Typically if you want your own content in the LOV you can use this feature.
In the below picture you can see the highlighted portion.
Ouput of the LOV by using this facet will more or less same as model driven LOV, with your own added feature to introduce the for table filtering, columnStretching, etc.
I have incorporated the Custom LOV with af Query, but you can use your own method for filtering.
Output:
Download : Source for InputListOfValues "searchContent" Facet
Typically if you want your own content in the LOV you can use this feature.
In the below picture you can see the highlighted portion.
Ouput of the LOV by using this facet will more or less same as model driven LOV, with your own added feature to introduce the for table filtering, columnStretching, etc.
I have incorporated the Custom LOV with af Query, but you can use your own method for filtering.
Output:
Download : Source for InputListOfValues "searchContent" Facet
RichInputListOfValues Select Exact Match LOV
There was a requirement given by OTN Forum posted by one of the user, regarding Exact Match LOV.
http://forums.oracle.com/forums/thread.jspa?threadID=2157132&tstart=30
Problem Statement :
LOVs in ADF match the entered value using a LIKE operation. For example, let's say we have an attribute of type String with an associated LOV. When entering the value 'V', even if the value 'V' exists, the LOV will open and show values matching 'V%' ('V', 'Va', 'Vb'...).
Is there any chance to prevent the LOV opening when the exact match exists?
I have prepared sample for achieving the same. In my sample i have taken DepartmentId in Employee Master.
In the XE data there will be data
Department Id : 10(Adminstration),100(Finance)...
In the regular LOV when the user types 10 even though exact match of 10 is there lov popup opens.
one of the problem statement in the below OTN url
http://forums.oracle.com/forums/thread.jspa?messageID=9203960
But prepared a generic code for LOV launch which will work both for Number datatype as well as Varchar Datatype.
Solution:
The base concept of the solution is in the LaunchPopupListener's LaunchPopupEvent where there is a provision to set the Launch i.e launchPopupEvent.setLaunch(false) and there is a method to check launchPopupEvent.isLaunchPopup(). with the two methods we can control the launching of the popup.
Then we need to identify whether user entered value matching with the records filtered. For this we need to get the JUCtrlListBinding's ListIterator where we can get the LOV iterator, in that we can check whether the entered value is having exact match in the iterator, if exact match found then we need to queue the return popup listener with the lauchpopupevent set launch to false.
Download Link: Sample For Exact Match LOV
http://forums.oracle.com/forums/thread.jspa?threadID=2157132&tstart=30
Problem Statement :
LOVs in ADF match the entered value using a LIKE operation. For example, let's say we have an attribute of type String with an associated LOV. When entering the value 'V', even if the value 'V' exists, the LOV will open and show values matching 'V%' ('V', 'Va', 'Vb'...).
Is there any chance to prevent the LOV opening when the exact match exists?
I have prepared sample for achieving the same. In my sample i have taken DepartmentId in Employee Master.
In the XE data there will be data
Department Id : 10(Adminstration),100(Finance)...
In the regular LOV when the user types 10 even though exact match of 10 is there lov popup opens.
one of the problem statement in the below OTN url
http://forums.oracle.com/forums/thread.jspa?messageID=9203960
But prepared a generic code for LOV launch which will work both for Number datatype as well as Varchar Datatype.
Solution:
The base concept of the solution is in the LaunchPopupListener's LaunchPopupEvent where there is a provision to set the Launch i.e launchPopupEvent.setLaunch(false) and there is a method to check launchPopupEvent.isLaunchPopup(). with the two methods we can control the launching of the popup.
Then we need to identify whether user entered value matching with the records filtered. For this we need to get the JUCtrlListBinding's ListIterator where we can get the LOV iterator, in that we can check whether the entered value is having exact match in the iterator, if exact match found then we need to queue the return popup listener with the lauchpopupevent set launch to false.
Note: If the generic launchpopup is used for Varchar attributes. Then the LOV ViewObject should have Orderby clause.
Below the code snippet for the generic launchpopup. Where we can call in the Listofvalues Launchpopup listener.Download Link: Sample For Exact Match LOV
public void lovcustomLaunch(LaunchPopupEvent launchPopupEvent) { String currentColumnName = null; String valueExpression = null; JUCtrlListBinding ctrlListBinding = null; ViewObject baseViewObject = null; AttributeDef lovAttributeDef = null; AttributeDef lovlistAttributeDef = null; ListBindingDef listBindingDef = null; String[] listAttributeNames = null; FacesCtrlLOVBinding.ListOfValuesModelImpl listOfValuesModel = null; ViewCriteria viewCriteria = null; Object submittedValue = null; ViewCriteriaRow viewCriteriaRow = null; RowSet rowSet = null; Row listRow = null; Row baseViewObjectRow = null; if (!launchPopupEvent.isLaunchPopup()) { return; } submittedValue = launchPopupEvent.getSubmittedValue(); if (submittedValue == null) { return; } BindingContext bindingContext = BindingContext.getCurrent(); BindingContainer bindingContainter = bindingContext.getCurrentBindingsEntry(); RichInputListOfValues inputListOfValues = (RichInputListOfValues)launchPopupEvent.getComponent(); if(inputListOfValues != null) { // below code gets the value expression for the current column i.e in our case #{bindings.DepartmentId.inputValue} valueExpression = inputListOfValues.getValueExpression(inputListOfValues.VALUE_KEY.getName()).toString(); if (valueExpression != null) { // if the column is in the af table then the value will be #{row.bindings.DepartmentId.inputValue} so we are replacing row. valueExpression = StringUtils.replace(valueExpression, "row.", ""); currentColumnName = valueExpression.substring(valueExpression.indexOf(".")+1, valueExpression.lastIndexOf(".")); if (currentColumnName != null) { ctrlListBinding = (JUCtrlListBinding)bindingContainter.getControlBinding(currentColumnName); if (ctrlListBinding != null) { baseViewObject = ctrlListBinding.getIteratorBinding().getViewObject(); if (baseViewObject != null) { baseViewObjectRow = baseViewObject.getCurrentRow(); lovAttributeDef = baseViewObject.findAttributeDef(currentColumnName); if (lovAttributeDef != null) { listBindingDef = lovAttributeDef.getListBindingDef(); if (listBindingDef != null) { listAttributeNames = listBindingDef.getListAttrNames(); if (listAttributeNames != null && listAttributeNames.length > 0) { listOfValuesModel = (FacesCtrlLOVBinding.ListOfValuesModelImpl)inputListOfValues.getModel(); if (listOfValuesModel != null) { viewCriteria = listOfValuesModel.getCriteria(); if (viewCriteria !=null) { viewCriteriaRow = (ViewCriteriaRow)viewCriteria.getRowAtRangeIndex(0); if (viewCriteriaRow != null) { lovlistAttributeDef = viewCriteriaRow.getStructureDef().findAttributeDef(listAttributeNames[0]); if (lovAttributeDef != null) { if (lovAttributeDef.getSQLType() == OracleTypes.NUMBER) { viewCriteriaRow.setAttribute(listAttributeNames[0], submittedValue); viewCriteriaRow.getCriteriaItem(listAttributeNames[0]).setOperator(JboCompOper.OPER_EQ); }else if (lovAttributeDef.getSQLType() == OracleTypes.VARCHAR) { viewCriteriaRow.setAttribute(listAttributeNames[0], submittedValue+"%"); viewCriteriaRow.getCriteriaItem(listAttributeNames[0]).setOperator(JboCompOper.OPER_LIKE); } listOfValuesModel.applyCriteria(); listOfValuesModel.performQuery(listOfValuesModel.getQueryDescriptor()); if (ctrlListBinding.getListIterBinding().getRowSetIterator() != null && ctrlListBinding.getListIterBinding().getRowSetIterator().getRowCount() > 0) { rowSet = ctrlListBinding.getListIterBinding().getRowSetIterator().getRowSet(); listRow = rowSet.getRowAtRangeIndex(0); if (listRow != null && listRow.getAttribute(listAttributeNames[0]).equals(submittedValue)) { if (baseViewObjectRow != null) { baseViewObjectRow.setAttribute(currentColumnName, submittedValue); } RowKeySetImpl rowKeySet = new RowKeySetImpl(); List list = new ArrayList(); list.add(listRow.getKey()); launchPopupEvent.setLaunchPopup(false); launchPopupEvent.queue(); inputListOfValues.queueEvent(new ReturnPopupEvent(inputListOfValues,rowKeySet)); AdfFacesContext.getCurrentInstance().addPartialTarget(inputListOfValues); } } } } } } } } } } } } } } }
Thursday, January 6, 2011
RichInputListOfValues Button Access Key and Advance Mode Visible false
Yesterday i saw in the OTN Forum about the Advance Option hide in ListOfValues
http://forums.oracle.com/forums/thread.jspa?threadID=2153584&tstart=0
I made a sample long time ago for setting access keys for "OK" and "Cancel" Buttons in ListOfValues, which Mr.Frank Nimphius has posted in "Nov-2010" month OTN Harvest. Further to the sample i thought of extending it to hide the Advance button option.
Download Link Sample For Access Key And Advance Hide
In the below output screen you can see that AccessKey for OK and Cancel And AdvanceMode of LOV is not visible.
Output Screen:
Program Logic :
Basically we need to get the LOV Object in our control which we can get after the popup is launched, for that we need af:serverlistener to call java method in our af:form.
For Invoking the ServerListener we need generate runtime javascript using ExtendedRenderKit which the current ListOfValues component Id as parameter to the ServerListener.
Inside the LaunchPopupListener we need to write the logic of adding the javascript.
<af:serverListener type="lovafterlaunch"
method="#{lovBean.lovAfterLaunch}"/>
The Script which is generated the at the runtime will invoke the method which we have mentioned in the serverlistener.
Inside the method we can access the RichPopup , RichDialog & RichQuery of the RichInputListOfValues by the below code.
http://forums.oracle.com/forums/thread.jspa?threadID=2153584&tstart=0
I made a sample long time ago for setting access keys for "OK" and "Cancel" Buttons in ListOfValues, which Mr.Frank Nimphius has posted in "Nov-2010" month OTN Harvest. Further to the sample i thought of extending it to hide the Advance button option.
Download Link Sample For Access Key And Advance Hide
In the below output screen you can see that AccessKey for OK and Cancel And AdvanceMode of LOV is not visible.
Output Screen:
Program Logic :
Basically we need to get the LOV Object in our control which we can get after the popup is launched, for that we need af:serverlistener to call java method in our af:form.
For Invoking the ServerListener we need generate runtime javascript using ExtendedRenderKit which the current ListOfValues component Id as parameter to the ServerListener.
Inside the LaunchPopupListener we need to write the logic of adding the javascript.
Next we need to Place the serverlistener in our jspx after af:form.public void lovLaunch(LaunchPopupEvent launchPopupEvent) { RichInputListOfValues inputListOfValues = RichInputListOfValues)launchPopupEvent.getComponent(); if (inputListOfValues != null) { FacesContext facesContext = FacesContext.getCurrentInstance(); String clientId = inputListOfValues.getClientId(facesContext); StringBuffer scriptBuffer = new StringBuffer(); scriptBuffer.append(" var docComp = AdfPage.PAGE.findComponent(\"f1\"); var comp = AdfPage.PAGE.findComponent(\""); scriptBuffer.append(clientId).append("\"); "); scriptBuffer.append(" if (comp != null && docComp != null) { var CompId = comp.getId(); "); scriptBuffer.append(" AdfCustomEvent.queue(docComp,\"lovafterlaunch\",{compId:CompId},true);}"); String script = scriptBuffer.toString(); ExtendedRenderKitService erks = Service.getService(facesContext.getRenderKit(), ExtendedRenderKitService.class); erks.addScript(facesContext, script); } }
<af:serverListener type="lovafterlaunch"
method="#{lovBean.lovAfterLaunch}"/>
The Script which is generated the at the runtime will invoke the method which we have mentioned in the serverlistener.
Inside the method we can access the RichPopup , RichDialog & RichQuery of the RichInputListOfValues by the below code.
public void lovAfterLaunch(ClientEvent clientEvent) { if (clientEvent.getParameters().size() > 0 && clientEvent.getParameters().get("compId") != null) { String compId = clientEvent.getParameters().get("compId").toString(); RichInputListOfValues inputListOfValues = (RichInputListOfValues)JSFUtils.findComponentInRoot(compId); if (inputListOfValues != null) { IteratorfacetNames = inputListOfValues.getFacetNames(); RichPopup richPopup = null; String facetName = null; UIComponent componentFacet = null; UIComponent componentdialog = null; while(facetNames.hasNext()) { facetName = facetNames.next(); if (facetName != null) { componentFacet = inputListOfValues.getFacet(facetName); if (componentFacet != null && componentFacet instanceof RichPopup) { richPopup = (RichPopup)componentFacet; break; } } } if (richPopup != null) { List uiCompList = richPopup.getChildren(); if (uiCompList.size() > 0) { componentdialog = uiCompList.get(0); if (componentdialog != null && componentdialog instanceof RichDialog) { RichDialog richDialog = (RichDialog)componentdialog; if (richDialog != null) { richDialog.setAffirmativeTextAndAccessKey("&OK"); richDialog.setCancelTextAndAccessKey("&Cancel"); AdfFacesContext.getCurrentInstance().addPartialTarget(richDialog); if (richDialog.getChildCount() == 1 && richDialog.getChildren().get(0) != null && richDialog.getChildren().get(0) instanceof RichPanelGroupLayout) { RichPanelGroupLayout panelGroupLayout = (RichPanelGroupLayout)richDialog.getChildren().get(0); uiCompList = panelGroupLayout.getChildren(); if (uiCompList.size() > 0 && uiCompList.get(0) != null && uiCompList.get(0) instanceof RichPanelHeader) { RichPanelHeader richPanelHeader = (RichPanelHeader)uiCompList.get(0); if (richPanelHeader.getChildCount() == 1 && richPanelHeader.getChildren().get(0) != null && richPanelHeader.getChildren().get(0) instanceof RichQuery) { RichQuery richQuery = (RichQuery)richPanelHeader.getChildren().get(0); if (richQuery != null) { richQuery.setModeChangeVisible(false); AdfFacesContext.getCurrentInstance().addPartialTarget(richQuery); } } } } } } } } } } }
Subscribe to:
Posts (Atom)