• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

jsf problem go from jsp page to another jsp in new window

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I’ve two jsp pages attendReport.jsp and printAttendReport.jsp
attendReport.jsp contains inputs for attend duration and employee id and command button “view” to view attendance data entered employee during entered duration inside the same page(this work very good)

the problem is the same page includes another command button “print” its job is to get the same data but view them in the second page printAttendReport.jsp in another window in order to print the data in some suitable format , but the print button opens attendReport.jsp instead of printAttendReport.jsp and does not hold the inputs else if I set <managed-bean-scope> to session not request which cause caching data , please help me if you to solve this problem

and here the related lines of code

<faces-config >
......
<managed-bean>
<managed-bean-name>attendReportBean</managed-bean-name>
<managed-bean-class>csc.attend.bean.AttendReportBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-action>#{AttendReportBean.attendReport}</from-action>
<from-outcome>attendReport</from-outcome>
<to-view-id>/attend/attendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<navigation-rule>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-action>#{AttendReportBean.printAttendReportAction}</from-action>
<from-outcome>printAttendReportAction</from-outcome>
<to-view-id>/attend/printAttendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>
.......

</faces-config>

public class AttendReportBean {
// data , getters and setters
{
init();
//Preload in initialization block.
}

public void init() {
// initialize data
}

public String attendReport() {
// code to get attend data to go to view page(same page) it is ok
return "attendReport"; // Navigation case.
}


public static String getRequestParameter(String name) {
return (String) FacesContext.getCurrentInstance().getExternalContext()
.getRequestParameterMap().get(name);
}

public void printAttendReportListener(ActionEvent event) {
String fromYearStr = getRequestParameter("fromYearAtt");
System.out.println("fromYearStr = "+fromYearStr);
....................
// try to get inputs through ActionListener but it gives me null
}

public String printAttendReportAction() {
// code to get attend data to go to print page(another page in new //window) but inputs come in default values

return "printAttendReportAction"; // Navigation case.
}

}


attendReport.jsp
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:view>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
/title . styles and validations /
</head>
<body>
<h:form id="attendReportForm">
/the form tag appear in running source as <form id="attendReportForm" method="post" action="/newdiwan/faces/attend/attendReport.jsp" enctype="application/x-www-form-urlencoded" >
i.e. it always submit to attendReport.jsp page
/


/ some inputs and outputs /
<h:commandButton onclick="return check();" id="view" action="#{attendReportBean.attendReport}" value="" styleClass="linksNumBlue" />
/it works good/
/ some outputs to view data /


<h:commandLink immediate="true" id="printLink" value="" action="#{attendReportBean.printAttendReportAction}" actionListener="#{attendReportBean.printAttendReportListener}" target="_blank" styleClass="linksNumBlue">

/this has two problems 1)submit to attendReport.jsp not printAttendReport.jsp which I want to go to.
2)does not get the inputs but return the default values only /
</h:form></body></html></f:view>

I use libraries { jsf-api.jar , jsf-impl.jar , jstl-1.1.0.jar and tomahawk-1.1.6.jar } and deploy on tomcat 6.0

I’m sorry for the prolongation, please help me if you can
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
use the [ code ] [ /code ] tag for code because otherwise your post becomes very difficult to read.

I don't think you need to specify both <from-action> and <from-outcome>
The navigation section of faces-config like this should be enough.

 
aly noor
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you Manu dv for your reply

I’ve two jsp pages attendReport.jsp and printAttendReport.jsp
attendReport.jsp contains inputs for attend duration and employee id and command button “view” to view attendance data entered employee during entered duration inside the same page(this work very good)

the problem is the same page includes another command button “print” its job is to get the same data but view them in the second page printAttendReport.jsp in another window in order to print the data in some suitable format , but the print button opens attendReport.jsp instead of printAttendReport.jsp and does not hold the inputs else if I set <managed-bean-scope> to session not request which cause caching data , please help me if you to solve this problem

and here the related lines of code

// here is managed bean code


attendReport.jsp

/the form tag appear in running source as <form id="attendReportForm" method="post" action="/newdiwan/faces/attend/attendReport.jsp" enctype="application/x-www-form-urlencoded" >
i.e. it always submit to attendReport.jsp page
/


/ some inputs and outputs /

//it works good/
// some outputs to view data /


//this has two problems 1)submit to attendReport.jsp not printAttendReport.jsp which I want to go to.
//2)does not get the inputs but return the default values only /

I use libraries { jsf-api.jar , jsf-impl.jar , jstl-1.1.0.jar and tomahawk-1.1.6.jar } and deploy on tomcat 6.0

I’m sorry for the prolongation, please help me if you can
 
aly noor
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
my problem solved 1- i use 2 managed bean , one of request scope (used in attendReport.jsp ) and the other with session scope (used in printAttendReport.jsp)
2 - add new jsp contains the h:commandLink of the print (attendReportPrintAction.jsp)
3 - divide the view of attendReport.jsp to two subviews (each subview has its own form) one contains inputs and outputs of attend and the other contains include to (attendReportPrintAction.jsp)
<%@ include file="attendReportPrintAction.jsp" %>

4 - send and get parameters using two methods
{code}
public static Object getSessionMapValue(String key) {
return FacesContext.getCurrentInstance().getExternalConte xt().getSessionMap().get(key);
}


public static void setSessionMapValue(String key, Object value) {
FacesContext.getCurrentInstance().getExternalConte xt().getSessionMap().put(key, value);
}
{code}

faces-config.xml
{code}
<managed-bean>
<managed-bean-name>attendReportBean</managed-bean-name>
<managed-bean-class>csc.attend.bean.AttendReportBean</managed-bean-class>
<managed-bean-scope>request</managed-bean-scope>
</managed-bean>

<managed-bean>
<managed-bean-name>print_attendReportBean</managed-bean-name>
<managed-bean-class>csc.attend.bean.AttendReportBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>

<navigation-rule>
<display-name>viewReport</display-name>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-action>#{AttendReportBean.attendReport}</from-action>
<from-outcome>attendReport</from-outcome>
<to-view-id>/attend/attendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>

<navigation-rule>
<display-name>printReport</display-name>
<from-view-id>/attend/attendReport.jsp</from-view-id>
<navigation-case>
<from-outcome>printAttendReportAction</from-outcome>
<to-view-id>/attend/printAttendReport.jsp</to-view-id>
</navigation-case>
</navigation-rule>
{code}

attendReportPrintAction.jsp
{code}
<f:subview id="printAttendReportSubView" >

<h:form id="printAttendReportForm" onsubmit="return check222();" >
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="11%">
<table width="70" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="7" height="28"><img src="../images/B-left.gif" width="7" height="28" /></td>
<td align="center" background="../images/B-bg.gif">
<h:commandLink id="printLink" value="طباعة" title="طباعة" action="#{print_attendReportBean.printAttendReport Action}" target="_blank" styleClass="linksNumBlue">
</h:commandLink>
</td>
<td width="7" height="28"><img src="../images/B-right.gif" width="7" height="28" /></td>
</tr>
</table>
</td>
<td align="right"> </td>
</tr>
</table>

</h:form>

</f:subview>{code}

i hope this helps someone
 
Please do not shoot the fish in this barrel. But you can shoot at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic