Passing Request Parameters to Non JSF Page

I want to pass request parameters from a JSF page (Page1.jsp) to a non JSF page (paramTest.jsp) and am having trouble.
The parameters are 'null' in the non JSF page.
Here is code (in Page1.java) that is called when 'button1' is clicked in Page1.jsp (modified from JSF, Bergsten p.167):
public String button1_action() {
        FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
        ExternalContext ec = context.getExternalContext();
        try {
            ec.redirect("http://xxx/paramTest.jsp");
        } catch (Exception e) {
            // print exception information in the server log
            log("Exception occurred when redirecting page", e);
            error("Trouble redirecting page");
            return null;
        context.responseComplete();
        return "success";
    }Here is Page1.jsp code: <?xml version="1.0" encoding="UTF-8"?>
<jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
    <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
    <jsp:text><![CDATA[
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
]]></jsp:text>
    <f:view>
        <html lang="en-US" xml:lang="en-US">
            <head>
                <meta content="no-cache" http-equiv="Cache-Control"/>
                <meta content="no-cache" http-equiv="Pragma"/>
                <title>Page1 Title</title>
                <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
            </head>
            <body style="-rave-layout: grid">
                <h:form binding="#{Page1.form1}" id="form1">
                    <h:inputText binding="#{Page1.name}" id="name" style="left: 144px; top: 96px; position: absolute"/>
                    <h:outputLabel binding="#{Page1.componentLabel1}" for="componentLabel1" id="componentLabel1" style="left: 72px; top: 96px; position: absolute">
                        <h:outputText binding="#{Page1.componentLabel1Text}" id="componentLabel1Text" value="Name:"/>
                    </h:outputLabel>
                    <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1" onclick="this.form.submit() style="left: 120px; top: 144px; position: absolute" value="Submit"/>
                    <h:messages binding="#{Page1.messageList1}" errorClass="errorMessage" fatalClass="fatalMessage" id="messageList1" infoClass="infoMessage"
                        showDetail="true" style="left: 480px; top: 72px; position: absolute" warnClass="warnMessage"/>
                </h:form>
            </body>
        </html>
    </f:view>
</jsp:root>Here is the rendered Page1.jsp html: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="en-US" lang="en-US">
<head>
<meta http-equiv="Cache-Control" content="no-cache"/><meta http-equiv="Pragma" content="no-cache"/>
<title>Page1 Title</title>
<link type="text/css" rel="stylesheet" href="resources/stylesheet.css"/>
</head>
<body style="-rave-layout: grid">
<form id="form1" method="post" action="/cenwkd/faces/Page1.jsp;jsessionid=79A5577F53DAAEDF164C5D33F33D8327" enctype="application/x-www-form-urlencoded">
<input id="form1:name" type="text" name="form1:name" style="left: 120px; top: 96px; position: absolute" />
<label id="form1:componentLabel1" for="form1:componentLabel1" style="left: 72px; top: 96px; position: absolute">
<span id="form1:componentLabel1Text">Name:</span></label>
<input id="form1:button1" type="submit" name="form1:button1" value="Submit" onclick="" style="left: 120px; top: 144px; position: absolute" />
<input type="hidden" name="form1" value="form1" />
</form>
</body>
</html> Here is the source for a test jsp, paramTest.jsp: <html>
<head>
<title>
paramTest
</title>
</head>
<body>
<h2><%= request.getParameter("form1:name")%></h2>
<%-- Also tried: request.getParameter("name"), "name" is the original 'id' value for the text field entered in Creator
     it apparently is changed to "form1:name" when the html is rendered--%>
</body>
</html>Here is the rendered html from paramTest.jsp: <html>
<head>
<title>
paramTest
</title>
</head>
<body>
<h2>null</h2>
</body>
</html>Any help would be much appreciated.

Hi,
I dont see any parameters that you are trying to pass in the below code.
public String button1_action() {
FacesContext context = javax.faces.context.FacesContext.getCurrentInstance();
ExternalContext ec = context.getExternalContext();
try {
ec.redirect("http://xxx/paramTest.jsp");
} catch (Exception e) {
// print exception information in the server log
log("Exception occurred when redirecting page", e);
error("Trouble redirecting page");
return null;
context.responseComplete();
return "success";
}

Similar Messages

  • JSF Page -- Backing Bean -- Non-JSF Page ...

    Hi
    I have a JSF page where the user enters data and submits by clicking on the Submit button. My backing bean then takes the data and processes it. After successful processing, I want to direct the user to a non-JSF page.
    What is the best way of achieving this?
    Thanks

    I am doing the following to get the desired effect now:
    FacesContext ctx = FacesContext.getCurrentInstance();
    ExternalContext ectx = ctx.getExternalContext();
    HttpServletResponse response = (HttpServletResponse)ectx.getResponse();
    String nextUrl = "....";
    response.sendRedirect(nextUrl);
    Is there a better way?

  • Use commandLink to forward non-jsf page cause other commandLink invalidate

    Hi :
    I use commandLink to forward to non jsf page , after click the link , it worked , success to 1.jsp. Then I click another link , the other commandLink doesn't work.
    any one have the same problem ?
    JSF page:
    <h:commandLink action="#{MenuHandler.go}">
         <h:outputText value="process" />
         <f:param value="1.jsp" name="forward" />
    </h:commandLink>
    MenuHandler.java
      public static String go() {
                HttpServletRequest req = getRequest();
                String forward = req.getParameter("forward");
                getExternalContext().redirect(forward);
                FacesContext.getCurrentInstance().responseComplete();
                return "success";
      }ps:there is one <h:form/> in my jsf page and I use:
    jdk1.5.0
    jsf-1_1
    Tomcat-5.0.28

    to supplement:
    I found something strange:
    The JSF page I used is for menu purpose.
    So there is a <BASE target="mainFrame"> tag in my JSF page.
    If I mark it . Then other commandLink can work ~~
    Because the page is a menu page , so I can't mark the <BASE target="mainFrame">

  • Newbie: what is the equivalent of passing request parameters?

    Hi-
    I am new to JSF. I have read many tutorials and articles. I still don't get one concept about passing parameters. Note: I don't want to store stuff in the session unless I have to.
    Let's say I have a page with a list of users. I layout the page with a panelGrid. Each row of the table has the first and last name of the user. If a user clicks on the name of a user on the user list, it should go to the user profile page. The backing bean for the user list page will be the UserListBean. It has a method called getUsers() that returns a List of User objects.
    For the View User page, I have a ViewUserBean. The ViewUserBean retrieve the entire profile for that user.
    How do I pass the user ID to the ViewUserBean? In struts, I would pass it as a request parameter (I would manually write the link URL with the userID). I know I can use the request like that in JSF, but that seems ugly. I looked at the code of the J2EE bookstore tutorial and it does a funky thing with all sorts of data stored in the session.
    What is the best way to request a page and "pass in" a userID?
    Thanks for your help.
    Adam

    I have a case on my current project very similar to your case. What you want, very simply, is an easy way to allow faces to handle URLs like http://www.domain.com/showUserDetails?userId=50
    The natural trouble is that when loading the page, there is no action to use to prefetch the User object based on the Request Parameters in JSF.
    All the solutions above either rely on the session or they are exceedingly complex. This case is actually very easy to do and is very straight forward using Managed Properties and a Request Scope bean...
    Here is the rather straight forward solution I used...
    First, make a "ShowUserDetailsBean" which represents the "logic" for this page.
    public class ShowUserDetailsBean
        /** Will point to the actual user service after dependency injection*/
        private UserService userService;
        /** Will hold the userId from the HTTP Request Parameters*/
        private String userId;
        /** Will hold a lazy loaded copy of the User object matching userId*/
        private User user;
        public void setUserService(UserService userService) {
            this.userService = userService;  //dependecy injection
        public void setUserId(String userId) {
           this.userId = userId;  //dependency injection
        /** Lazy loads the User object matching the UserId */
        public User getUser() {
            //Trap the case where the URL has no userId
            if (userId == null) return null;
            if (user == null) {
                user = userService.getUser(userId);  //Lazy Load
            return user;
    }Next, configure the managed properties in faces-config.xml
    <faces-config xmlns="http://java.sun.com/JSF/Configuration">
      <managed-bean>
        <managed-bean-name>userService</managed-bean-name>
        <managed-bean-class>foo.UserServiceImpl</managed-bean-class>
        <managed-bean-scope>application</managed-bean-scope>
      </managed-bean>
      <managed-bean>
        <managed-bean-name>showUserDetails</managed-bean-name>
        <managed-bean-class>foo.ShowUserDetailsBean</managed-bean-class>
        <managed-bean-scope>request</managed-bean-scope>
        <managed-property>
          <property-name>userService</property-name>
          <property-class>foo.UserService</property-class>
          <value>#{userService}</value>
        </managed-property>
        <managed-property>
          <property-name>userId</property-name>
          <property-class>java.lang.String</property-class>
          <value>#{param.userId}</value>
        </managed-property>
      </managed-bean>Finally, you just make your webpage as you normally would...
    <h:outputText value="#{showUserDetails.user.userId}"/>
    <h:outputText value="#{showUserDetails.user.firstName}"/>
    <h:outputText value="#{showUserDetails.user.lastName}"/>
    Now you're ready to test, so you visit the page
    http://www.domain.com/showUserDetails?userId=50
    And your user details with userId=50 appears!
    It's just that simple!
    Regards,
    Doug
    Caveat: I haven't added any sample logic to handle cases where you visit:
    http://www.domain.com/showUserDetails
    without specifying a userId. I suggest you add some basic logic to your page to handle this case more gracefully.

  • Passing URL parameters to PL/SQL Pages

    Hi,
    I want to pass parameters from url to the PL/SQL page . How is this possible?
    http://myserver/pls/portal/url/PAGE/page_group/page/testplsqlpage?course_ref=##COURSE_ID##&staff_ref=##STAFF_ID##
    I will to received course_ref and staff_ref in the PL/SQL page and pass the values to SQL query so that its filtered.
    Can pls anyone guide me? If there is any alternate way or there is sample code pls let me know
    Many Thanks
    Ganesh

    Hi Mick,
    Thanks for your reply. However my problem is still not resolved.
    I have created a Omniportlet with lists the staff details. When I click on the staff link I am passing to parameters as follows
    http://servername/pls/portal/url/PAGE/CCM_MIS_PORTAL/TUTOR_HOME/Course_Info?Param1=10017031/M2523&Param2=001434
    on the receving page I have a omni portlet which must receive these 2 parameters and pass it on to the query and filter the results.
    On the received page I have created 2 page parameters (Param1 and Param2)
    I have assigned these 2 paramaters to the portlet paramers through page parameters' section
    on the omni portlet in the query I have created 2 bind variables (p1, p2) and the default value of the bind variable is set using ##Param1## and ##Param2## so the received values from page is passed to to bind variable and hence to the query.
    However the omni portlet is not received the parameters and I can not figure out whats wrong?
    Is there any problem with my URL (guide says I should use relative URL)
    Please help

  • How to pass request parameters using html:link in struts

    Hi All,
    I am trying to send parameters to action class using <html:link>.
    Can anybody give sample code how to do it?
    Thanks in advance.
    By
    K.Siva Prasad Reddy

    hi,
    you can pass the parameters in link like this
    http://www.xyz.com&username=someuserID&password=somePassword
    username and password are parameters which you want to pass as paramets to server..hope this will work for you...
    Thanks
    Surya

  • JSF and links with parameters to restore jsf page state

    Hi,
    I've been developing a forum using JSF. It's going to be something similar to the one we are just using.
    If a user, while browsing forum, find something interesting he should have a possiblity to copy URL form his browser and give it to his friend.
    The URL should contain all necesary parameters to restore a same view (a subpage of a forum etc) a first user had. What's best approach to do it ?
    Say, I have a few AJAX components on a forum page, how can I restore their states ? What's even more interesting how can I generate add parameters to URL in a browser ?
    I've found a good solution for my problem:
    [http://ocpsoft.com/prettyfaces/]
    "PrettyFaces is an OpenSource extension with enhanced support for +JavaServer
    Faces+ - JSF 1.1, 1.2 and 2.0 - enabling creation of bookmark-able,
    pretty URLs. PrettyFaces solves the "RESTful URL" problem elegantly,
    including features such as: page-load actions, seamless integration with
    faces navigation, dynamic view-id assignment, managed parameter
    parsing, and configuration-free compatibility with other web frameworks"

    best approach would be http://www.phpbb.com/ :-)
    seems crazy going to all that hassel, phpbb is so simple, infact a lot of jsf forums such as primefaces [http://primefaces.prime.com.tr/forum/] use phpbb, as you can have your fourm up and running in no time
    Edited by: pNev on 3 Meith 2010 00:38

  • Forwarding requests on to non-java pages from servlet.

    I have designed a web application using a form of single controller pattern.
    I have a number of JSPs.
    Each of these JSP's has a form element which if submitted got to a single servlet (Controller)which then forwards on the request to a different class based on the paramter passed. For example this form would call the SubmitFeedback class.
    <form name="feedbackform" method="post" action="<%=request.getContextPath()%>/controller">
    <input type="hidden" name="action" value="SubmitFeedback"/>
    <input type="hidden" name="page"   value="feedback.jsp">
    <tr><td><input type="submit" name="go" value="Go"/></td></tr>
    </table>
    </form>After the class has done its processing it returns what page to go next to the Controller class and this forwards the request on. to the next jsp
    String nextPage = createAction(request.getParameter(PARAM_ACTION)).handleRequest(this,request, response, request.getParameter(PARAM_PAGE));          
    request.getRequestDispatcher(nextPage).forward(request, response);
    return;This is all fine but now I have a sitation where after the user submits the form I want do some processing then forward them onto another page which is not part of my system, nor java. But the RequestDispatcher is only for the current Context within a Servlet Container.
    Could someone explain how I do this, what am Im missing please.

    i am not a JavaScript expert, so I can't be sure this is everything, but:
    1) The javascript has to be put inside a <script></script> block (you also had an extra close bracket):
    <script type="text/javascript">
      <!--
      function validateAccept() {
        toReturn=true;
        if (form.accept.checked==false) {
          alert("You must select at least one checkbox to search");
          toReturn=false;
        return toReturn;
      //-->
    </script>The script block is usually put in the head section also, but that is not necessary.
    2) I would call this function from the onsubit event of the form rather than the onclick of the submit button
    <form  name="form" action="..." method="post" onsubmit="return validateAccept();">
      //...3) You will need to identify the form that you want to use inside the function. Just using the name form won't work, it has to be retrieved from a certain context. The easiest thing is to pass it in as a parameter:
    <script type="text/javascript">
      <!--
      function validateAccept(form) {
    <form  name="form" action="..." method="post" onsubmit="return validateAccept(this);">

  • Problem with Non JSF Request to JSF Page

    Hi All,
    I am working on dynamic controls generation based on the request come from non jsf page
    For the first request, pageworks perfectly. but when we go for second request, it is not rendering and I am getting same old page.
    What I have identified is if I have 2 pages as JSF, application is not giving any problem.
    For this I have written small test application contains both JSF pages only.
    page1 contains 3 submit buttons.
    When submit buttons are clicked based on the request, I get, am able to see the dynamic controls.
    SO there is no problem with JSF PAGE to JSF Page Communication
    Now I have done some changes in First JSF page. Instead of submitting directly I am submitting the page through JavaScript which is nonb JSF request. There I am facing the problem and based on requested qaction I am not able to see correct rendered page based on the requested action.
    Any Idea why it is giving problem for non JSF requests??
    Thanks
    Sudhakar

    For Your Convenience in understanding the problem
    I am pasting entire test code
    Page 1 -- (here page2 is Page1 and Page1 is page2 - some naming convention errors :) )
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <jsp:text><![CDATA[
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    ]]></jsp:text>
        <f:view>
            <html lang="en-US" xml:lang="en-US">
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>Page2 Title</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                    <h:form binding="#{Page2.form1}" id="form1">
    <!-- Non JSF REquests -->
                        <h:commandButton action="#{Page2.button1_action}" binding="#{Page2.button1}" id="button1" style="left: 48px; top: 48px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=1'; document.forms['form1'].submit(); return false;"/>
                        <h:commandButton action="#{Page2.button2_action}" binding="#{Page2.button2}" id="button2" style="left: 48px; top: 96px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=2'; document.forms['form1'].submit(); return false;"/>
                        <h:commandButton action="#{Page2.button3_action}" binding="#{Page2.button3}" id="button3" style="left: 48px; top: 144px; position: absolute" value="Submit" onclick="document.forms['form1'].action='faces/Page2.jsp?id=3'; document.forms['form1'].submit(); return false;"/>
    <!-- this  is JSF request -->
                        <!--
                        <h:commandButton action="#{Page2.button1_action}" binding="#{Page2.button1}" id="button1" style="left: 48px; top: 48px; position: absolute" value="Submit" />
                        <h:commandButton action="#{Page2.button2_action}" binding="#{Page2.button2}" id="button2" style="left: 48px; top: 96px; position: absolute" value="Submit" />
                        <h:commandButton action="#{Page2.button3_action}" binding="#{Page2.button3}" id="button3" style="left: 48px; top: 144px; position: absolute" value="Submit" />-->
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>Page1 Bean
    * Page2.java
    * Created on June 25, 2005, 11:08 AM
    * Copyright user
    package webapplication8;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import javax.faces.component.html.*;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    public class Page2 extends AbstractPageBean {
        // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
        private int __placeholder;
        private HtmlForm form1 = new HtmlForm();
        public HtmlForm getForm1() {
            return form1;
        public void setForm1(HtmlForm hf) {
            this.form1 = hf;
        private HtmlCommandButton button1 = new HtmlCommandButton();
        public HtmlCommandButton getButton1() {
            return button1;
        public void setButton1(HtmlCommandButton hcb) {
            this.button1 = hcb;
        private HtmlCommandButton button2 = new HtmlCommandButton();
        public HtmlCommandButton getButton2() {
            return button2;
        public void setButton2(HtmlCommandButton hcb) {
            this.button2 = hcb;
        private HtmlCommandButton button3 = new HtmlCommandButton();
        public HtmlCommandButton getButton3() {
            return button3;
        public void setButton3(HtmlCommandButton hcb) {
            this.button3 = hcb;
        // </editor-fold>
        public Page2() {
            // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
            try {
            } catch (Exception e) {
                log("Page2 Initialization Failure", e);
                throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
            // </editor-fold>
            // Additional user provided initialization code
        protected webapplication8.ApplicationBean1 getApplicationBean1() {
            return (webapplication8.ApplicationBean1)getBean("ApplicationBean1");
        protected webapplication8.SessionBean1 getSessionBean1() {
            return (webapplication8.SessionBean1)getBean("SessionBean1");
         * Bean cleanup.
        protected void afterRenderResponse() {
        public String button1_action()  throws Exception{
            // TODO Following code was replaced by static navigation
           getSessionBean1().setId(1);       
          /* ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
           return null;*/
            return "case1";
        public String button2_action()  throws Exception{
            // TODO Following code was replaced by static navigation
                getSessionBean1().setId(2);
          /*  ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
           return null;*/
            return "case2";
        public String button3_action() throws Exception{
            // TODO Following code was replaced by static navigation
                getSessionBean1().setId(3);
            /*    ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
           HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
           HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
           res.sendRedirect("http://localhost:18080/webapplication8/faces/Page2.jsp");
            return null;*/
            return "case3";
    }page 2
    <?xml version="1.0" encoding="UTF-8"?>
    <jsp:root version="1.2" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:jsp="http://java.sun.com/JSP/Page">
        <jsp:directive.page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"/>
        <jsp:text><![CDATA[
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    ]]></jsp:text>
        <f:view>
            <html lang="en-US" xml:lang="en-US">
                <head>
                    <meta content="no-cache" http-equiv="Cache-Control"/>
                    <meta content="no-cache" http-equiv="Pragma"/>
                    <title>Page1 Title</title>
                    <link href="resources/stylesheet.css" rel="stylesheet" type="text/css"/>
                </head>
                <body style="-rave-layout: grid">
                    <h:form binding="#{Page1.form1}" id="form1">
                        <h:panelGrid binding="#{Page1.gridPanel1}" id="gridPanel1" style="left: 96px; top: 48px; position: absolute"/>
                        <f:selectItems binding="#{Page1.radioButtonList1SelectItems1}" id="radioButtonList1SelectItems1"/>
                        <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1"
                            style="left: 384px; top: 120px; position: absolute" value="Submit"/>
                        <h:commandButton action="#{Page1.button1_action}" binding="#{Page1.button1}" id="button1" style="left: 384px; top: 72px; position: absolute" value="Submit"/>
                        <h:outputLink binding="#{Page1.hyperlink1}" id="hyperlink1" style="left: 480px; top: 216px; position: absolute" value="http://www.sun.com/jscreator">
                            <h:outputText binding="#{Page1.hyperlink1Text}" id="hyperlink1Text" value="Hyperlink"/>
                        </h:outputLink>
                        <h:commandLink binding="#{Page1.linkAction1}" id="linkAction1" style="left: 456px; top: 264px; position: absolute">
                            <h:outputText binding="#{Page1.linkAction1Text}" id="linkAction1Text" value="Link Action"/>
                        </h:commandLink>
                    </h:form>
                </body>
            </html>
        </f:view>
    </jsp:root>page2 bean
    * Page1.java
    * Created on June 25, 2005, 10:52 AM
    * Copyright user
    package webapplication8;
    import javax.faces.*;
    import com.sun.jsfcl.app.*;
    import com.sun.jsfcl.data.DefaultSelectItemsArray;
    import java.util.Vector;
    import javax.faces.component.UIComponent;
    import javax.faces.component.UISelectItems;
    import javax.faces.component.html.*;
    import javax.faces.context.ExternalContext;
    import javax.faces.context.FacesContext;
    import javax.faces.el.ValueBinding;
    import javax.faces.model.SelectItem;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    public class Page1 extends AbstractPageBean {
        // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Definition">
        private int __placeholder;
        private HtmlForm form1 = new HtmlForm();
        public HtmlForm getForm1() {
            return form1;
        public void setForm1(HtmlForm hf) {
            this.form1 = hf;
        private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();
        public HtmlPanelGrid getGridPanel1() {
            return gridPanel1;
        public void setGridPanel1(HtmlPanelGrid hpg) {
            this.gridPanel1 = hpg;
        private HtmlCommandButton button1 = new HtmlCommandButton();
        public HtmlCommandButton getButton1() {
            return button1;
        public void setButton1(HtmlCommandButton hcb) {
            this.button1 = hcb;
        private HtmlOutputLink hyperlink1 = new HtmlOutputLink();
        public HtmlOutputLink getHyperlink1() {
            return hyperlink1;
        public void setHyperlink1(HtmlOutputLink hol) {
            this.hyperlink1 = hol;
        private HtmlOutputText hyperlink1Text = new HtmlOutputText();
        public HtmlOutputText getHyperlink1Text() {
            return hyperlink1Text;
        public void setHyperlink1Text(HtmlOutputText hot) {
            this.hyperlink1Text = hot;
        private HtmlCommandLink linkAction1 = new HtmlCommandLink();
        public HtmlCommandLink getLinkAction1() {
            return linkAction1;
        public void setLinkAction1(HtmlCommandLink hcl) {
            this.linkAction1 = hcl;
        private HtmlOutputText linkAction1Text = new HtmlOutputText();
        public HtmlOutputText getLinkAction1Text() {
            return linkAction1Text;
        public void setLinkAction1Text(HtmlOutputText hot) {
            this.linkAction1Text = hot;
        // </editor-fold>
        public Page1() {
            // <editor-fold defaultstate="collapsed" desc="Creator-managed Component Initialization">
            try {
                ExternalContext ctx=(ExternalContext)FacesContext.getCurrentInstance().getExternalContext();
                HttpServletRequest req=(HttpServletRequest)ctx.getRequest();
                HttpServletResponse res=(HttpServletResponse)ctx.getResponse();
                String id=req.getParameter("id");
                if(id!=null)
                    getSessionBean1().setId(Integer.parseInt(id));
                if (getSessionBean1().getId()==1) {
                    addTextBox();
                else if (getSessionBean1().getId()==2) {
                    addCheckBox();
                    addRadio();
                else if (getSessionBean1().getId()==3) {
                    addRadio();
                   // addCheckBox();
            } catch (Exception e) {
                log("Page1 Initialization Failure", e);
                throw e instanceof javax.faces.FacesException ? (FacesException) e: new FacesException(e);
            // </editor-fold>
            // Additional user provided initialization code
        protected webapplication8.ApplicationBean1 getApplicationBean1() {
            return (webapplication8.ApplicationBean1)getBean("ApplicationBean1");
        protected webapplication8.SessionBean1 getSessionBean1() {
            return (webapplication8.SessionBean1)getBean("SessionBean1");
         * Bean cleanup.
        protected void afterRenderResponse() {
        private void addRadio() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Desc");
            outputText.setId("somedesc2");
            HtmlSelectOneRadio checkBox = new HtmlSelectOneRadio();
            checkBox.setBorder(0);
            checkBox.setLayout("pageDirection");
            checkBox.setId("a3");
            UISelectItems items = new UISelectItems();
            DefaultSelectItemsArray objArray =new DefaultSelectItemsArray();
            vectDefaultSelectItemsArray.add(objArray);
            arrays=(DefaultSelectItemsArray[])vectDefaultSelectItemsArray.toArray(new DefaultSelectItemsArray[vectDefaultSelectItemsArray.size()]);
            int size =arrays.length;
            arrays[size - 1].clear();
            for (int i =0;i<10;i++) {
                arrays[size - 1].add(new SelectItem(""+i+"",""+i));
            // array.setItems(new String[] {"Yes","No" });
            items.setValueBinding("value",getValueBinding("#{Page1.arrays["+(size-1)+"]}"));
            checkBox.getChildren().add(items);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(checkBox);
            parent.getChildren().add(gridPanel);
        private void addCheckBox() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Desc");
            outputText.setId("somedesc1");
            HtmlSelectManyCheckbox checkBox = new HtmlSelectManyCheckbox();
            checkBox.setBorder(0);
            checkBox.setLayout("pageDirection");
            checkBox.setId("a2");
            UISelectItems items = new UISelectItems();
            DefaultSelectItemsArray objArray =new DefaultSelectItemsArray();
            vectDefaultSelectItemsArray.add(objArray);
            arrays=(DefaultSelectItemsArray[])vectDefaultSelectItemsArray.toArray(new DefaultSelectItemsArray[vectDefaultSelectItemsArray.size()]);
            int size =arrays.length;
            arrays[size - 1].clear();
            for (int i =0;i<10;i++) {
                arrays[size - 1].add(new SelectItem(""+i+"",""+i));
            // array.setItems(new String[] {"Yes","No" });
            items.setValueBinding("value",getValueBinding("#{Page1.arrays["+(size-1)+"]}"));
            checkBox.getChildren().add(items);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(checkBox);
            parent.getChildren().add(gridPanel);
        private void addTextBox() {
            HtmlPanelGrid gridPanel = new HtmlPanelGrid();
            UIComponent parent = gridPanel1;
            HtmlOutputText outputText = new HtmlOutputText();
            outputText.setValue("Some Description for Control Text Box");
            outputText.setId("somedesc");
            HtmlInputText textField = new HtmlInputText();
            //  textField.setId("textField_"+control.getId());
            textField.setId("a1");
            HtmlOutputText outputText1 = new HtmlOutputText();
            hyperlink1Text.setValue(" ");
            hyperlink1Text.setStyleClass("bodyText");
            textField.setStyleClass("frmObjects");
            gridPanel.setColumns(3);
            gridPanel.getChildren().add(outputText);
            gridPanel.getChildren().add(hyperlink1Text);
            gridPanel.getChildren().add(textField);
            parent.getChildren().add(gridPanel);
        private DefaultSelectItemsArray array = new DefaultSelectItemsArray();
        public DefaultSelectItemsArray getArray() {
            return array;
        public void setArray(DefaultSelectItemsArray dsia) {
            this.array = dsia;
        private Vector vectDefaultSelectItemsArray = new Vector();
        private DefaultSelectItemsArray[] arrays = new DefaultSelectItemsArray[10];
        public DefaultSelectItemsArray[] getArrays() {
            return arrays;
        public void setArrays(DefaultSelectItemsArray[]dsia) {
            this.arrays = dsia;
        private UISelectItems radioButtonList1SelectItems1 = new UISelectItems();
        public UISelectItems getRadioButtonList1SelectItems1() {
            return radioButtonList1SelectItems1;
        public void setRadioButtonList1SelectItems1(UISelectItems uisi) {
            this.radioButtonList1SelectItems1 = uisi;
        private ValueBinding getValueBinding(String expression) {
            return     FacesContext.getCurrentInstance().getApplication().createValueBinding(expression);
        public String button1_action() {
            // TODO Replace with your code
            return "case1";
    }my navigation.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
        <navigation-rule>
            <from-view-id>/Page2.jsp</from-view-id>
            <navigation-case>
                <from-outcome>case1</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>case2</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
            <navigation-case>
                <from-outcome>case3</from-outcome>
                <to-view-id>/Page1.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
        <navigation-rule>
            <from-view-id>/Page1.jsp</from-view-id>
            <navigation-case>
                <from-outcome>case1</from-outcome>
                <to-view-id>/Page2.jsp</to-view-id>
            </navigation-case>
        </navigation-rule>
    </faces-config>my managed beans xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
                                  "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
        <managed-bean>
            <managed-bean-name>Page1</managed-bean-name>
            <managed-bean-class>webapplication8.Page1</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>SessionBean1</managed-bean-name>
            <managed-bean-class>webapplication8.SessionBean1</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>ApplicationBean1</managed-bean-name>
            <managed-bean-class>webapplication8.ApplicationBean1</managed-bean-class>
            <managed-bean-scope>application</managed-bean-scope>
        </managed-bean>
        <managed-bean>
            <managed-bean-name>Page2</managed-bean-name>
            <managed-bean-class>webapplication8.Page2</managed-bean-class>
            <managed-bean-scope>request</managed-bean-scope>
        </managed-bean>
        <managed-bean>
    </faces-config>

  • Actions/submitting non JSF forms to JSF pages

    Ok, I am new to JSF so bear with me,
    I am trying to execute some logic BEFORE displaying a JSP/JSF page - a simple example of this is checking if user is logged in, or getting data for the page based on parameters passed in from a non-JSF page (or on URL line), or deciding which page to display, etc. In other words similar to struts action.
    Seems basic but I cant figure out how to do it without placing logic into JSPs. All examples I see seem to require a submit from a JSF page to get to the controller logic. What am I missing?
    Thanks.

    I decide the struggling is a sheer waste of time and hurts future reusability and maintainability.
    Write a set of JSF embedded JSPs from scratch.
    Or give a try to: https://facelets.dev.java.net/

  • Passing jsf parameters to a jsp page

    how to access the parameters declared in jsf page from a jsp page.
    in the jsp page I need to access the paramaters something like request.getParameter("age");
    how to declare the same in the jsf page in h form.
    <h:form>
    <h:inputText value="" id = "age" />
    </h:form>
    and in the jsp page i should access this parameter like request.getParameter("age");
    how to accomplish this.
    Please help.

    Please don't doublepost. Continue here: http://forum.java.sun.com/thread.jspa?threadID=5252759

  • Passing parameters from one OAF page to another OAF PAge

    Hello
    I was wondering, if there is a possibility of passing request parameters from one page to another page in EBS ( E-Business Suite).
    I tried using the following
    a) PageContext.putParamater ( "MyParamater", "ParamaterValue")
    b) I addded the above line of code by extending an page controller of the OAF page and personalized the page
    When I am trying to retrieve the value by getParameter() in the next page. I am also unable to get access to the parameter in the next page.
    I am trying the above code while trying to create expenses in I-Expense module...I would like to pass the ReportHeaderId from one page to another page for customization purposes. I Am not able to get ReportHeaderId in the ReviewPAge...There are no Business Objects in the Review page...hence trying the putParameter idea.
    Any help will be highly appreciated
    Thank You

    What is the source of the parameter? If the source is a VO, you can use the method I have specified in my previous post regarding updating the button properties. For example, you can include the param in the destination URL of the button as such:
    OA.jsp?page=/xyz/oracle/apps/.../myPG&retainAM=Y&addBreadCrumb=Y&myParam={@ParamSource}
    where ParamSource is an attribute from a VO.
    You can get this value via oapagecontext.getParameter()
    Can you please give details as to the source of your params (param-1, param-2, etc.). This will help in providing you suggestions.
    Regards,
    LC

  • What is the best way to Process non-JSF request??

    I am engaged in new project using JSF.
    We came across the serious problem that there is no-way
    to let JSF execute action method of managed bean at the
    first request.
    That is because, JSF gets method binding information only
    from pre-displayed UIComponent, it seems impossible to
    let JSF know about the method binding info when they receive
    the request from external system, or from non-JSF pages i n the
    same system.
    I get to two ways to solve this problem.
    1. develop a custom-servlet
    The tasks of the custom servlet is,
    - receive a request from external system or non-JSF pages.
    - get managed bean and execute it's action method.
    - get next page info
    - dispatch to next page through FacesServlet
    2. use bridge-JSF page as a intermediation
    This is kind of last resort.
    As I described above, JSF can get method binding info, only
    from components of pre-displayed pages.
    So, I use bridge -JSF page to let it work as a intermediation.
    It displays nothing, just click the commandbutton automatica
    lly(by JavaScript).
    Of-cource, I prefer 1 to 2.
    Codes below are custom servlet sample , I made.
    Pls let me know if it's ok or not.
    thanks
    public class FESFacesServlet extends HttpServlet{
        public void doPost(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
    /* init process */
            LifecycleFactory lFactory = (LifecycleFactory)
                                            FactoryFinder.getFactory(FactoryFinder.LIFECYCLE_FACTORY);
            Lifecycle lifecycle = lFactory
                                    .getLifecycle(LifecycleFactory.DEFAULT_LIFECYCLE);
            FacesContextFactory fcFactory = (FacesContextFactory)
                                                FactoryFinder.getFactory(FactoryFinder.FACES_CONTEXT_FACTORY);
            FacesContext facesContext = fcFactory.getFacesContext(getServletContext(), request, response,lifecycle);
            Application application = facesContext.getApplication();
    /* set from-view-id */
            ViewHandler viewHandler = application.getViewHandler();
            String viewId = request.getParameter("fromviewid");
            UIViewRoot view = viewHandler.createView(facesContext, viewId);
            facesContext.setViewRoot(view);
    /* find managed bean and execute it's action method */
            ManagedBeanBase managedBean = (ManagedBeanBase)application.getVariableResolver().
                                                    resolveVariable(facesContext, request.getParameter("command"));
            String outCome = managedBean.start();
    /* look for next page info */
            NavigationHandler navigationHandler = application.getNavigationHandler();
            navigationHandler.handleNavigation(facesContext, null, outCome);
    /* dispatch to next page throw FacesServlet */    
            facesContext.getExternalContext().dispatch("/faces" + facesContext.getViewRoot().getViewId());
            facesContext.release();
        public void doGet(HttpServletRequest request, HttpServletResponse response ) throws ServletException, IOException {
            this.doPost(request,response);
    -

    the common approach is kind of like your number 2)
    but you dont need a commandButton
    just have your first page redirect to your start page
    e.g.
    index.html
    <html>
    <head>
    <!�redirect to startPage -->
    <meta http-equiv="Refresh" content= "0; URL=index.faces"/>
    <title>Start Web Application</title>
    </head>
    <body>
    <p>Please wait for the web application to start.</p>
    </body>
    </html>

  • How to send a request parameter to a dialog pages with jsf

    I'm using the dialog framework of oracle, java server faces.......
    I need to open a url on a dialog page(request scope), and I must to pass request parameters. I put <f:param> objects inside the commandLink who I click.....
    If the page is not dialog, it woks fine, but when I put in a dialog way.... nothing work
    =[
    anyone know what I have to do?
    thanks

    Hi, I suppose you have already seen the ADF DIalog Framework, isn't it?
    I think there tells how to pass parameter
    A workaround is to save them in your session and then get them back and remove

  • HOWTO: command_button, action and request parameters HOWTO

    Starting from carDetail.jsp example:
    Click of button:
    <h:command_button
    action="#{carstore.storeFrontLuxuryPressed}"
    value="#{bundle.moreButton}" >
    </h:command_button>
    Method Invoked:
    public String storeFrontLuxuryPressed() {
         setCurrentModelName("Luxury");
         return "carDetail";
    Navigation case "carDetail" maps to:
    <navigation-rule>
    <from-view-id>/storeFront.jsp</from-view-id>
    <navigation-case>
    <description>
    Any action that returns "carDetail" on storeFront.jsp should
    cause navigation to carDetail.jsp
    </description>
    <from-outcome>carDetail</from-outcome>
    <to-view-id>/carDetail.jsp</to-view-id>
    </navigation-case>
    </navigation-rule>
    So I imagine that a forward is done to carDetail.jsp
    At this point I want to daviate from the sample. I would like to pass request parameters to carDetail.jsp
    like:
    carDetail.jsp?mode=create&date=25-Dec-2003
    I want my managed bean in carDetail.jsp to get populated from request scope. The managed bean in config looks something like this:
    <managed-bean>
    <description>this is for item test bean.</description>
    <managed-bean-name>PageParams </managed-bean-name>
    <managed-bean-class> com.a.PageParams</managed-bean-class>
    <managed-bean-scope> request </managed-bean-scope>
    <managed-property>
    <property-name>mode</property-name>
    <value>#{requestScope.mode}</value>
    </managed-property>
    <managed-property>
    <property-name>date</property-name>
    <value>#{requestScope.date}</value>
    </managed-property>
    </managed-bean>
    How should I code the following method to pass the request parameters to the next page:
    public String storeFrontLuxuryPressed() {
         setCurrentModelName("Luxury");
    //Can I do anything here to help navigation system to pass additional request parameters to
    //the carDetail.jsp page
         return "carDetail";
    Please help as I have many pages that have command_button and control leads to other pages that take request parameters to initialize and set themselves up. And I can't understand how to make the two concepts work together?
    Thanks,
    Vinay

    Thx hunangdp
    your solution of using <f:parameter> is perfect #in case# <h:command_button> is not nested inside <h:data_table> , otherwise the request parameter passed will always show the value of the 1st row , not the clicked row .
    consider the following :
    <h:data_table var="item" value="#{shoppingCartBean.shoppingItems}" >
    <h:column>
    <h:command_link value="#{item.productId}" action="product" id="productAction">
    <h:output_text value="#{item.productName}"/>
    <f:parameter name="productId" value="#{item.productId}"/>
    </h:command_link>
    </h:column>
    </h:data_table>
    in this case using the following at the back end :
    FacesContext fc = FacesContext.getCurrentInstance();
    java.util.Map requestParameter = fc.getExternalContext().getRequestParameterMap();
    String value = requestParameter.get("productId");
    will return the value of the 1st row ..
    so if, instead I consider adding an action listener which set the request attribute "productId" to the command_link value , this will work , but I have to get the value from request attribute not the request parameter ==> :
    <h:data_table var="item" value="#{shoppingCartBean.shoppingItems}"
    rowClasses="InnerTable">
    <h:column>
    <h:command_link value="#{item.productId}" action="product" id="productAction">
    <h:output_text value="#{item.productName}"/>
    <f:action_listener type="mybean.Listener"/-->
    </h:command_link>
    </h:column>
    </h:data_table>
    and mybean.listener ==> :
    String id = (String) ((UICommand) event.getComponent()).getValue();
    HttpServletRequest request = (HttpServletRequest)facesContext.getExternalContext().getRequest();
    request.setAttribute("productId", id);
    any comments.. ?

Maybe you are looking for

  • Best way to write SELECT statement

    Hi, I am selecting fields from one table, and need to use two fields on that table to look up additional fields in two other tables. I do not want to use a VIEW to do this.  I need to keep all records in the original selection, yet I've been told tha

  • ORDER-TO-CASH OTC Extraction

    Hello All, Would appreciate if you can explain me OTC in relation to BW. What are the extractors, what specific reports are generated for order-to-cash. I promise to award points to helpful answer. Thanks for your time. Pramod.

  • Generic Extractor for MCH1 data

    I need to extract data to BW in which the source of data is the table MCH1.  I could not find any content extractors - does anyone know if one exists? Thanks

  • REGARDING CONVERSION OF SPOOL (XML FORMAT ) INTO READABLE FORMAT

    HELLO EVRYONE, I AM GETTING MY SMARTFORM OUTPUT IN XML FORMAT ON SPOOL, I WANT TO CHECK IT SO I NEED THAT XML OUTPUT IN TEXT FORMAT OR ANY OTHER READABLE FORMAT, PLEASE REPLY ME. ITS URGENT. THANKS & REGARDS, VIMARSH B.

  • # of dimensions

    Hi all,I have a cube (1) with 12 dimensions and the block size is 361648. I created another cube (2) and merged 2 sparse dimensions so I have 11 dimensions in the cube but the interesting part is that my block size is still the same 361648. Can someo