By default AppModule is configured to database through the
connection created in JDeveloper. But if we want to change the connection type
to “JDBC DataSource” from “JDBC URL”, it expects a Datasource name as an input.
But we need to pass the JNDI name to this field instead of data source name.
Wednesday
How to display a message dialog on the JSF page
The below code will be used to display a message dialog on
the JSF page.
FacesContext
facesContext = FacesContext.getCurrentInstance();
FacesMessage
facesMessage = new FacesMessage(message);
facesMessage.setSeverity(severity);
facesContext.addMessage(null, facesMessage);
Where message is
the message what we want to display on the dialog box and severity is to show the severity of the message. Example for
severity is FacesMessage.SEVERITY_INFO which displays the dialog box as an
information message. Inputs for severity is available in FacesMessage class.
Creating GraphDataModel object for pieGraph
When creating a dvt:pieGraph, an object of GraphDataModel
class needs to be passed as input to it.
The below code helps to understand how to create
GraphDataModel object.
In the below code, I am taking data from database.
|
public static GraphDataModel getGraphDataModel(String table, String cust_id) throws Exception {
String[]
columnLabels = { "" };
String[]
columnNames = getColumnNames(table);//User defind Method, returns all column names of the given table
int size =
columnNames.length;
if
(ignoreFields != null)
size =
size - ignoreFields.size();
Object[][]
data2 = new Object[1][size];
String[]
seriesLabels = new String[size];
Connection
con = createConnection(); //Method to return connection object
Statement
stmt = con.createStatement();
StringBuilder query = new StringBuilder("SELECT * FROM " +
table+ "where cust_id="+cust_id);
System.out.println("Query
of graph: " + query);
ResultSet rs
= stmt.executeQuery(query);
if
(rs.next()) {
for (int
i = 0, j = 0; i < columnNames.length && j < size; i++) {
if
("cust_id".equals(columnNames[i]))
continue;
seriesLabels[j] = columnNames[i];
data2[0][j] = new Double(rs.getDouble(i + 1));
j++;
}
}
rs.close();
stmt.close();
con.close();
oracle.dss.dataView.LocalXMLDataSource ds =
new
oracle.dss.dataView.LocalXMLDataSource(columnLabels,
seriesLabels, data2);
GraphDataModel graphData =
new
oracle.adf.view.faces.bi.model.GraphDataModel();
graphData.setDataSource(ds);
return
graphData;}
|
Subscribe to:
Posts (Atom)