Get the display value of selectonechoice or LOV in bean – Oracle ADF

I found one approach to get the display value of LOV in managed bean using  ADFUtils.evaluateEl method.

Say if you have a value change listener for an lov,  valueChangeEvent.getNewValue() gives the index of the value. To get the display value of the lov, use below logic  :

public void onDeptNameChange(ValueChangeEvent valueChangeEvent) {

Object deptNameAttribute = ADFUtils.evaluateEL("#{bindings.deptName.items['"+valueChangeEvent.getNewValue().toString()+

"'].label}");

String deptNameStr = deptNameAttribute .toString();  // This should have the selected display value of lov.

}

Say if you want to access the display value of LOV, in any other method, other than valueChange listener, then use below code :

Object deptNameAttribute = ADFUtils.evaluateEL("#{bindings.deptName.items['"+ADFUtils.getBoundAttributeValue("deptId")+"'].label}");

Here deptId is the code of this lov.  Hope this is helpful.

Happy learning with Techartifact……

Fetching server name and port number for ADF application

Requirement – How to get server name and server port.
Solutions- You can get this information in by writing below code in java

FacesContext fctx = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fctx.getExternalContext ().GetRequest ();
String serverName = request.getServerName();
int serverPort =request.getServerPort();

System.out.println ("Server Name:" + serverName);
System.out.println ("Server Port no:" + server port);

Happy coding with Vinay Kumar in Techartifact.

Difference in RowCount Vs EstimatedRowCount Vs FetchedRowCount in ADF

Being an ADF developer,there are few method which is very confusing .So lets discuss method which fetch row count of VO>
Sometimes in ADF applications, we need to count the number of rows, as shown in the table .If we don’t understand these method , it will create a big performance problem.

getRowCount() -> getRowCount() retrives all the records from View Object by executing ViewObject Query.The count is calculated by traversing the Viewobject using next() method until the
last record is retrived. This method hinders the performance of application in case of VO with large number of rows.

getEstimatedRowCount() -> When you need to get quick count of row.Use this method. Method getEstimatedRowCount() actually retrives the count by hitting getQueryHitCount() which runs the select count(*) on the VO query.

getFetchedRowCount() -> Method getFetchedRowCount() counts the number of rows from the Result Set.Returns the number of rows fetched at that point of time.

In Short –

-> When you need to iterate all row to get or check some attribute value use getRowCount().It can create problem issue.
-> When you just need an count of table use getEstimatedRowCount().

If the application, we need to traverse the rowset all records, such as some of the above every line to get attribute values, you can choose to use getRowCount () method;
And if we only need to know the number of rows set the time, then use getEstimatedRowCount () method,