Monday, 9 September 2013

how to know which page are requsted in jsf

how to know which page are requsted in jsf

I have two pages that diracting to MainReport page , so I want to know if
the MainPage is requested from page1 do Something , else do something else
..
how to know which page is calling main page ?
my main page class :
public TableBean() {
SID & from & to from page1 QueryString
String SID = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get("SID");
String from = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get("from");
String to = FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get("to");
// class_id from page 2 QueryString
String class_id = FacesContext.getCurrentInstance()
.getExternalContext().getRequestParameterMap().get("class_id");
// if requsted from page2 do the following Try ...
try {
Dbconnection NewConnect = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Statement stmt = con.createStatement();
ResultSet rs = stmt
.executeQuery("SELECT a.course_id, a.teacher_id,
a.class_id, a.day_id, a.state, a.apssent_date,
a.interval_id,s.student_id,s.first_name FROM Student AS s
INNER JOIN Apsent AS a ON s.student_id = a.student_id
where apssent_date between '"
+ from
+ "' and '"
+ to
+ "' and a.class_id = "
+ class_id);
List<Integer> ids = new ArrayList<Integer>();
List<String> names = new ArrayList<String>();
List<Integer> intervals = new ArrayList<Integer>();
List<Integer> teachers = new ArrayList<Integer>();
List<String> dates = new ArrayList<String>();
final List<String> state = new ArrayList<String>();
while (rs.next()) {
ids.add(rs.getInt(8));
names.add(rs.getString(9));
intervals.add(rs.getInt(7));
teachers.add(rs.getInt(2));
dates.add(rs.getString(6));
state.add(rs.getString(5));
}
} catch (Exception ex) {
System.out.println(ex);
}
try {
Dbconnection NewConnect = new Dbconnection();
Connection con = NewConnect.MakeConnect();
Statement stmt = con.createStatement();
ResultSet rs = stmt
.executeQuery("SELECT a.course_id, a.teacher_id,
a.class_id, a.day_id, a.state, a.apssent_date,
a.interval_id,s.student_id,s.first_name FROM Student AS s
INNER JOIN Apsent AS a ON s.student_id = a.student_id
where apssent_date between '"
+ from
+ "' and '"
+ to
+ "' and s.student_id = "
+ SID);
List<Integer> ids = new ArrayList<Integer>();
List<String> names = new ArrayList<String>();
List<Integer> intervals = new ArrayList<Integer>();
List<Integer> teachers = new ArrayList<Integer>();
List<String> dates = new ArrayList<String>();
final List<String> state = new ArrayList<String>();
while (rs.next()) {
ids.add(rs.getInt(8));
names.add(rs.getString(9));
intervals.add(rs.getInt(7));
teachers.add(rs.getInt(2));
dates.add(rs.getString(6));
state.add(rs.getString(5));
}
carsSmall = new ArrayList<Car>();
populateRandomCars(carsSmall, ids.size(), ids, names, intervals,
teachers, dates, state);
} catch (Exception ex) {
System.out.println(ex);
}
}

No comments:

Post a Comment