Use request attributes in JSF

Is there a way we can pass data from one form bean to the other using request attributes insted of session attributes?
I am able to work with session attributes using
HttpSession mySession = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(true); and setting attributes to it, but getting null pointers(occassionally) when I retrieve the atribute and work with it.
getSession(false) isnt helping either.
Looks like facesServlet is creating a new request when it forwards to next page. Any idea on how to get the Faces Servlet do something like request despatcher forward, for navigation so I can work with request attributes?
Appreciate your input.

Can I have just one backing bean and use it for all jsps in the app? App has 4 flows from home page and mutiple jsps in each flow. Each jsp has multiple form fields. Is that OK?
Any way to passing data/objects between different backing beans - other than using session attributes? I had similar problems working on Struts app as well.

Similar Messages

  • Using TAG Attributes within JSF Tags

    I'm using some .tag files for templating purposes. I'm using two tag attributes via <@% attribute %> directive. How can i access this attribute to do something like follows.
    <%@ tag display-name="Area de Trabajo" language="java" %>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <%@ taglib prefix="t" uri="http://myfaces.apache.org/tomahawk"%>
    <%@ attribute name="title" required="true"%>
    <%@ attribute name="location" %>
    <t:div styleClass="zonaArea#{(not empty location) ? location : 'Global'}">
      <h:panelGrid columns="1">
        <h:outputText value="#{title}" />
      </h:panelGrid>
      <jsp:doBody />
    </t:div>

    Hola Alberto.
    Any luck? Did you worked that around?
    I'm just trying to do the same thing...
    Tried to do something like:
    <%@attribute name="enabled" type="java.lang.String" %>
    <h:outputText value="test: #{requestScope['enabled']}" style="font-weight: bold;" /> to no avail...
    Let me know, please!
    Hi,
    Manrico

  • Using  Request Processor with JSF (No Struts)

    Hi
    Im doing some analysis on JSF. My requirement is that I do need the Request Processor of struts to be fit in my architecture. However we are not using Struts. How can the same be achieved using JSF?
    Any help would be much appreciated
    Thanks

    Hi
    Im doing some analysis on JSF. My requirement is that I do need the Request Processor of struts to be fit in my architecture. However we are not using Struts. How can the same be achieved using JSF?
    Any help would be much appreciated
    Thanks

  • PLZ Help: how to get value of a request scoped Bean/Attribute in JSF ?!!!

    hi,
    I noticed this part of code to retrieve session scoped beans/vars in an ActionListener or other jsf classes, but it does not work for request scoped beans/vars :( what's the problem then ? what shall i do ?
    Type var = (Type)Util.getValueBinding("myBeanInRequest")).getValue(context);
    I have also set that getPhaseId() returns UPDATE_MODEL_VALUES or APPLY_REQUEST_VALUES.
    Any comment or idea ?

    I have declared my Bean in my JSP page not in the
    faces-config.xml. Does this make any problem ? Also I
    have tried the way you told me as well, but still the
    returned attribute is null.
    P.S. My bean is declared in my JSP page this way:
    <jsp:useBean id="newSurveyVar" class="SurveyModel"
    scope="request" />
    This declaration causes the SurveyModel instance to be created in request scope when the page is rendered, but that doesn't help you when the form is submitted -- that is going to happen on the next request (so the request attribute created here goes away). Basically, <jsp:useBean> is not typically going to be useful for request scope attributes (it's ok for session or application scope, though).
    and further I have this jsf code:
    <h:command_button label="Create" commandName="create"
    action="create" >
    <f:action_listener
    r type="CreateNewSurveyActionListener"/>
    </h:command_button>
    and this is my
    CreateNewSurveyActionListener.processAction(ActionEvent
    e) {
    if (actionCommand.equals("create_the_survey")) {
    FacesContext context =
    t = FacesContext.getCurrentInstance();
    SurveyModel survey =
    y =
    (SurveyModel)(Util.getValueBinding("newSurveyVar")).get
    alue(context);
    if (survey==null) // returns true :(((
    And since I've declared my beans here there is nothing
    special declared in my faces-config.xml
    For me again it is really strange why it is not
    working !!!
    Any idea ? Because the event listener is fired in a separate request, so the one you created in the page is gone.
    This is why the managed bean creation facility was created. If your component contains a valueRef that points at the bean name (or you evaluate a ValueBinding as illustrated earlier in the responses to your question), then the bean will get instantiated during the processing of the form submit.
    Craig McClanahan

  • How to polulate data from lookup using request dataset in OIM 11g

    Hi,
    Using Request dataset in OIM 11g, I need to display one dropdown with the roles those need to come from Lookup.
    For Ex; I have 2 resources,i.e Resource A and Resource B. Resource A has 5 roles and Resource B has 3 Roles.
    While creating a request, If I select Resource A, then I should be able to get 5 Roles and if I select Resource B then I should be able to see corresponding 3 roles.
    Pls. note I have only one Look up definition , where I have roles for both Resource A and B.
    I have done simillar thing in OIM 10g , however I am unable to do it using OIM 11g Request dataset.
    Pls suggest.

    Hi BB,
    I am trying to follow up your response.
    You are suggestng to use prepopulate adapter for to populate respource object name, that means We have to just use an sql query from obj tabke to get the resource object name. right ?? it could be like below, what should I have entity-type value here ??
    <AttributeReference name="Field1" attr-ref="act_key"
    available-in-bulk="false" type="Long" length="20" widget="ENTITY" required="true"
    entity-type="????"/>
    <PrePopulationAdapter name="prepopulateResurceObject"
    classname="my.sample.package.prepopulateResurceObject" />
    </AttributeReference>
    <AttributeReference name="Field2" attr-ref="Field2" type="String" length="256" widget="lookup-query"
    available-in-bulk="true" required="true">
    <lookupQuery lookup-query="select lkv_encoded as Value,lkv_decoded as Description from lkv lkv,lku lku
    where lkv.lku_key=lku.lku_key and lku_type_string_key='Lookup.xxx.BO.Field2'
    and instr(lkv_encoded,concat('$Form data.Field1', '~'))>0" display-field="Description" save-field="Value" />
    </AttributeReference>
    Then I need think about the 'Lookup.xxx.BO.Field2' format.
    Could you please let me know if my understanding is correct?? What is the entity-type value of the first attribute reference value?
    Thanks for your all help.

  • How to use extends attribute in jsp page directive

    Can anybody tell how to extend a existing .jsp file from another .jsp file. I have tried but it gives error.
    I have used Extends attribute of page directive as below:
    <%@ page extends = "MyAnotherJsp.jsp"%>
    I also tried : <%@ page extends = "MyAnotherJsp"%>
    I am using Tomcat as a web server
    Also tell where to put those files.
    Thanks.

    Hi I am using Netbeans 5.5, Sun Java System Application Server 9.
    ABC.java
    package javapackage;
    public class ABC{
    public String show(){
    return "Sandip Gaikwad";
    index.jsp
    <%@ page extends="javapackage.ABC" %>
    <html>
    <head>
    <title>JSP Page</title>
    </head>
    <body>
    <h1>JSP Page </h1>
    </body>
    </html>
    Above code throws following exception at runtime:-
    HTTP Status 500 -
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] F:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\Page_Extends_Attribute_Example\org\apache\jsp\index_jsp.java:36: getPageContext(javax.servlet.Servlet,javax.servlet.ServletRequest,javax.servlet.ServletResponse,java.lang.String,boolean,int,boolean) in javax.servlet.jsp.JspFactory cannot be applied to (org.apache.jsp.index_jsp,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,,boolean,int,boolean)
    [javac] pageContext = _jspxFactory.getPageContext(this, request, response,
    [javac] ^
    [javac] 1 error
    Server log
    StandardWrapperValve[jsp]: Servlet.service() for servlet jsp threw exception
    org.apache.jasper.JasperException: Unable to compile class for JSP
    Generated servlet error:
    [javac] F:\Sun\AppServer\domains\domain1\generated\jsp\j2ee-modules\Page_Extends_Attribute_Example\org\apache\jsp\index_jsp.java:36: getPageContext(javax.servlet.Servlet,javax.servlet.ServletRequest,javax.servlet.ServletResponse,java.lang.String,boolean,int,boolean) in javax.servlet.jsp.JspFactory cannot be applied to (org.apache.jsp.index_jsp,javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,<nulltype>,boolean,int,boolean)
    [javac] pageContext = _jspxFactory.getPageContext(this, request, response,
    [javac] ^
    [javac] 1 error
    at org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:94)
    at org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:384)
    at org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:461)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:528)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:507)
    at org.apache.jasper.compiler.Compiler.compile(Compiler.java:495)
    at org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:530)
    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:324)
    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:412)
    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:318)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
    at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:397)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:278)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:240)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:179)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:73)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:182)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at com.sun.enterprise.web.VirtualServerPipeline.invoke(VirtualServerPipeline.java:120)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:137)
    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:566)
    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:536)
    at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:939)
    at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:239)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.invokeAdapter(ProcessorTask.java:667)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.processNonBlocked(ProcessorTask.java:574)
    at com.sun.enterprise.web.connector.grizzly.ProcessorTask.process(ProcessorTask.java:844)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.executeProcessorTask(ReadTask.java:287)
    at com.sun.enterprise.web.connector.grizzly.ReadTask.doTask(ReadTask.java:212)
    at com.sun.enterprise.web.connector.grizzly.TaskBase.run(TaskBase.java:252)
    at com.sun.enterprise.web.connector.grizzly.WorkerThread.run(WorkerThread.java:75)
    If I delete the line <%@ extends="javapackage.ABC"%> it works fine. Please tell me what is wrong with this line.

  • 'Requested attribute is invalid' error

    I'm attempting to programmatically get (and ultimately set) camera attributes with CVI. I can get some attribute values, such as ROI_WIDTH using the imgGetAttribute function, but not all, and not the ones that I really need to access, which are 'Exposure Time' and 'Gain Value'. I can see and set these exposure time and gain value camera attributes in MAX. However, when I attempt to use the imgGetCameraAttributeString function in IMAQ to get these attributes, I get the error 'The requested attribute in invalid'. My camera is the Basler acA2040-180km. In all other respects - snapping, grabbing, etc. the camera interface works fine.
    I cannot see what I am doing wrong or what piece I am missing, but it is obviously something. I took the NI example 'Analog attributes' as a starting point but that yields the same errors. How can MAX manipulate these camera attributes but I cannot in CVI? Is there some setup piece that is missing? 
    I'm kinda new to this environment, but would much appreciate any help anyone has.
    Thanks in advance,
    Wayne Showalter
    Solved!
    Go to Solution.

    Hi Wayne,
    IMAQ differerentiates in behavior and API with respect to 'IMAQ attributes' (defined by the IMAQ driver) and 'Camera Attributes' (defined by the camera file). All the ones with fixed constants (like ROI_WIDTH) are IMAQ attributes while the ones that specifically set something in the camera are camera attributes. You'll need to use the Get/SetCameraAttribute API for those. There are different functions for String vs Numeric attributes. I suspect if you call it with imgSetCameraAttributeNumeric() it will work.
    Eric

  • Set request attributes from the request attributes

    Using struts chaining actions.
    When using chaining the requestAttributes are lost.
    Is there a way to get all the request attributes and set them back to the request again?
    if so how to do this?
    Thanks.

    Looks like nobody knows :(
    It seems odd that nobody's tried to get InputSelectLOV or DataHandler working with a Struts app...
    ... anyway, on to finding out why the thing's throwing my releasemode away. This really is very like swimming through treacle :(

  • Cannot reliably use request.getRequestURL() in my backing bean

    I am using jDev 11.1.2.3.0.
    In my backing bean to my ADF JSF page fragment I get mixed results from different web browsers when trying to retrieve a URL from the request object. The java code I use in my bean is like this:
    FacesContext fc = FacesContext.getCurrentInstance();
    HttpServletRequest request = (HttpServletRequest)fc.getExternalContext().getRequest();
    String URL = request.getRequestURL().toString();
    Depending on whether I use IE, Firefox or Chrome, sometimes the URL = null. What's wierder is that different computers in my office get different results. One computer can get URL = null in IE and FF, and another would get null using Chrome and IE. It's so bizzare, I don't even know where to start debugging this issue.
    But I'm wondering if it's the way I am retrieving the request object using request = (HttpServletRequest)fc.getExternalContext().getRequest(); Is this the right way to get the request object?

    Hi,
    if you are in a page fragment then the request is partial anyway. So can you give us an idea of what the use case is for which you need the URL ? Maybe its easier to fix the desired use case implementation then to fix access to the URL just to find out you cannot use the result (the URL is not identifying the page fragment and thus doesn't allow redirects or bookmarks)
    Frank

  • How to use ternary operator in JSF using EL expression

    how to use ternary operator in JSF using EL expression

    I want to use ternary operator for h:datatable columnclasses attribute like as below
    <h:datatable
    columnClasses="#{booleanExpression ? style1,style2 : style3,style4}"
    />
    But it's not working.Is there any other alternative to do this?

  • Source Used Item Attribute

    Hi All,
    I am using HTML DB 2.0. I am a new user of HTMLDB. Please explain the difference between 2 Source Used Item Attribute
    1. Always, replacing an existing value in session state
    2. Only when current value in session state is null.
    If there is already a thread on this, please give me the link.
    Thanks in advance
    Monika

    So are you saying that this behaviour is different in v1.6?Yes. Otherwise the PPR stuff wouldn't work when those requests referenced uncommitted session state.
    You mean, "will NOT be able to ..."No, it will be able to see the value of the item (in uncommitted session state). That's the change from 1.6.
    What is an example of a "session-state committing source method"? Code that not only sets the source of the item for display but as a side-effect cause update_cache_with_write to occur for that item or for any other item(s). For example a PL/SQL Function source type that returns the source value and also does :P1_ITEM := 'value'; .
    Scott
    Message was edited by:
    sspadafo

  • ID attribute in JSF components

    Hello,
    I have a question about the id attribute on JSF 2 components.
    The document says, that it should be a String. Does that mean
    String constant or could it also be a el-expression resulting to a String.
    Actually I can use el-expression for id, but am not sure because of the documentation.
    Any infos about that would be great!

    Well, I stick with documentation. This is a specification. That means other iplementations like Apache myFaces
    will also stick to the documentation not for current mojorra implementation or others.
    That means, an implementation must not evaluate an el-expression. We ar here talking about evaluationg an
    el-expression and the documentation says, that id must not evaluate el-expressions. At least thats what i understand.
    So when i use mojorra and use el-expressions fpr id and change to apache implementation of jsf, i might be
    not working.
    Also i would get same result, if mojorra implementation someday does not evaluate el-expressions.
    So it is very important for me and i guess for JSF to clear this point cause it is important for development.
    One of the posters above mentioned it, is it possible to set dynamic ids for components or not.
    I always read that it is not wanted. Ids will be generated. But you can give a component an constant id.
    Like you can easy read in the documentation.
    You are interpreting the documentation. But JSF is a specification and should not let room for interpretations.
    If el-expressions are allowed it should be it should be documented.
    By the way, I think in apache implementation of JSF, el-expressions for id is not allowed.
    See here:
    http://www.mail-archive.com/[email protected]/msg20800.html
    So this implementation does exactly what documentation is saying so for me, mojorra implementation has here a bug!
    Edited by: 859302 on 18.05.2011 05:23

  • Passing Request Attributes in betweeen pageflow Portlets

    Hi
    How to pass Request Attributes in between Pageflow Portlets
    I tried with ScopedServletUtils class but it's not working for me
    Thanks

    Consider using events to pass data between portlets. Refer to docs about
    Interportlet Communication (IPC).
    Subbu
    Srinivasa Reddy Kapidi wrote:
    Hi
    How to pass Request Attributes in between Pageflow Portlets
    I tried with ScopedServletUtils class but it's not working for me
    Thanks

  • Request attribute vs parameter

    Hi all,
    I am getting confused of request attribute and request parameter. What i understand is that a parameter is a piece of info that send with the request. Such that infomation (parameter) come from a form component (text field, radiobuttion,selection...). By using servlet.getParameter("my text filed") i can retrieve what user enter into the form.
    In the similar maner, if from one servlet, i use request.setAttribute("a message","content of a message") i can also retrive the content of the message from another servlet using getAttribute.
    In short, parameter is for form-servlet communication and attribute is for servlet-servlet communication, am i correct? Can I change the parameter of the request from a servlet?
    Is there any other different between these 2?
    Thai
    Message was edited by:
    lnthai2002

    I still dont get it. You said
    HttpServletRequest doesnt have get/setAttribute(arg0, arg1) method.
    But it does. http://java.sun.com/javaee/5/docs/api/
    Again, my concern is whether i can exchange value of parameter and attribute. Assuming the following scenario:
    a user want to access a protected servlet /financial. This servlet notice that the user has not been login yet. Thus, it record the url of the request as a attribute:
    //inside /financial servlet
    if((req.getSession(false).getAttribute("curUser")) == null)
          dest="/WEB-INF/docs/authentication/login.jsp";
          req.setAttribute("oriUrl",req.getRequestURL());
          } then it forward the request to login.jsp. After user input his infomation, the login.jsp send a NEW request with the user's credential to the /authentication servlet. Now, as you can see, when the authentication servlet receive the request, it doesnt know that the user was trying to access the /financial servlet before because the oriUrl attribute is lost. What i getting at here is how I can retain the oriUrl attribute over requests? I need to capure that attribute and associate it with a new request as a parameter. But HOW?
    Hope you can help
    Message was edited by:
    lnthai2002

  • Is deriving or check Change Request attributes in DERIVE_ENTITY or CHECK_ENTITY

    Hi,
    I'd have a requirement to derive or check  the Change Request attributes like Change Request Reason and Change Request Priority , e.g if CR Priority is empty, set to a specific value or Check if Change Request Reason is set.
    I know via an OSS message that we are not able to derive or check CR attributes using BRF+ but can we derive or check using the BADI?

    The BRF+ and BAdI solutions are directed more towards the master data entities. If you "only" want to default or check the CR header, then one idea is to enhance the CR Header handler class. Please see this document that describes how to enhance the CR Header. You don't need to add a field, but you can learn the technique of adding checks, etc. to the GenIL model handler class.
    Enhancement of the User Interface Building Bloc... | SCN

Maybe you are looking for

  • External HD

    I've deleted lots of big files on my external HD and it still shows the same amount of memory usage when I click on "get info". Am I missing a step? How do I get an updated assesment of how much memory is available.

  • Status Record - Inbound

    Hi, I am using a custom FM that accepts Delevry02 idoc which is just being used as a place holder. I am updating me22 and va02 transaction after certain logic. When i checked the status of idoc, it is set to 50(idoc added). As it is a test idoc, do i

  • Need help with export, truncate and import partitions for schema

    I need to export a couple partions for our Oracle 10g Data Warehouse, truncate the partions and re-import the data using the exported file. How can I do this? In summary here is what I need to do: 1) Export partition P_SUB_1 of table1 2) Export parti

  • SP Citi Double Cash CLI!

    Just went online and figured I would try for a CLI from Citi, as I've recently gotten CLIs from both Amex and Discover, and I'm glad to report it was a success!!!  Instantly approved for double my previous limit, $1,500 --> $3,000 That brings me toAm

  • Is there any way to add the column in the verifier table?

    Hi folks, I am new to WFR.I am using AP solution project.While sending my invoice to WFR,I can see that one column is not picked by the verifier table.Can I use Supervise Learning to add the column there?Will this configuration be supported by Oracle