Ajax and the Request scope

Hi,
I have a cfm page with a html div tag. When the page loads a
cfc function is called which in turn does a cfinclude to populate
the div tag. If I do a <cfdump var="#request#"> in the
included page, it outputs the request variables fine.
However, when the user clicks a button an ajax call is made
to another cfc function which includes a cfm file again and returns
the output of the function (as a cfsavecontent var) back to the
original page and then this content is displyaed in the div tag. My
problem is when I try to use a request variable in the second
included page it is not available.
I think this may be because the page is called using
XMLHttpRequest instead of HttpRequest?
Does anyone know if this is the case?
Thanks.

Have you tried using CFDIV?

Similar Messages

  • How To Pass the Request Scope To Another Class

    In my ListThread class, I first retrieve some of the text fields; i.e., request.getParameter( ... );
    Thereafter, I want to pass the request scope together with some parameters to another class; SiteUtil.java., for some further processing. This is what I do:
    public final class ListThread extends HttpServlet
          public doPost( HttpServeltRequest request, HttpServlerResponse response)
                      throws ServletException, IOException
          String offset = request.getParameter( "offset" );
          String size = request.getParameter( "size" );
          SiteUtil.prepareNavigate( request, offset, size,
               MessageInboxConfig.ROWS_IN_THREADS );
    }This is my SiteUtil.java:
    import javax.servlet.http.HttpServletRequest;
    public class SiteUtil
       public static void prepareNavigate  
         (HttpServletRequest request, int offset, int   
                         collectionSize, int totalRows)
          int startOffset = offset + 1;
          int lastOffset = offset + collectionSize;
          request.setAttribute("StartOffset", new Integer(startOffset));
          request.setAttribute("LastOffset", new Integer(lastOffset));
    }Can I pass the request scope and save attributes in the scope this way?

    You can pass the request to that method as a parameter, yes, and you can even modify the request there. The request is just an ordinary Java object, so ordinary Java rules apply. Your code looks fine to me too.
    However don't try to store the request for future use, since after the response is sent back to the client, the request object is never used again. A new one is created for the next request.

  • How to get the request scope values?

    Hi,
    I have one question about Struts validate framework question is How can i get the request scope values when the validate method throws an exception?
    My scenario is I have some values in the request scope in one page. After submitting the page the validate method throws an exception, then the errors were displayed in the page and it ask for provide correct information. However, at this time the values in the first request will become null. How can I get those request values?
    Request.setAttribute(�con�, conn);Link after click this link user will display with user reg. form with user details input fields. After submitting he user details form if user provide some invalid information then validate method in Action form will throw errors and displayed the User details form with errors. However, the request attribute �con� will become null at this point of time. How can I get the user request attribute in user details form?
    Assume request have more than 100 values.
    Waiting for answer...
    Regards,
    Bhaskar Reddy

    Your code is probably fine, and you are probably running into http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6497210
    See also http://forum.java.sun.com/thread.jspa?messageID=9419890
    SUN needs to fix a few bugs for this to work...

  • Command Link in the af:table Component can not Work in the Request Scope

    Actually, the problem is that when we click on the command link, the action method #{overview.goToLinkAction} is not triggered.
    Here is the codes of action method "goToLinkAction" on the backing bean:
    public String goToLinkAction() {
    String linkString = (String) AdfFacesContext.getCurrentInstance()
    .getProcessScope().get("linkString");
    System.out.println("Link String is: " + linkString);
    return "";
    The data object list "listOfTransefer" for af:table is composed first time when the page is initialized.
    public void onPageLoad() {
    this.listOfTransfers = composeListOfTransfers();
    But when the commandlink or commandbutton is clicked to pose the form, this onPageLoad method is ignored by using PagePhaseListener:
    public void beforePhase(PagePhaseEvent event) {
    FacesPageLifecycleContext ctx =
    (FacesPageLifecycleContext)event.getLifecycleContext();
    if (event.getPhaseId() == Lifecycle.PREPARE_MODEL_ID && needReload()) {
    bc = ctx.getBindingContainer();
    onPageLoad();
    bc = null;
    public final boolean needReload() {
    if (!isPostback())
    return Boolean.TRUE;
    else
    return alwaysReload();
    protected boolean isPostback() {
    return Boolean.TRUE.equals(resolveExpression("#{adfFacesContext.postback}"));
    That means the method "onPageLoad()" may not be invoked when the commandlink is clicked.
    Is there any way to resolve this problem without changing the scope of the backing bean to "session"?
    Your response will be very helpful for us.
    Thanks

    Hi,
    if you implicitly say that this works if the managed bean is in session scope then the problems seems to me that one of your evaluation criterias is reset in the request scope, which I think most likely is the needReload() method. Did you add debug statements to the methods to see where exactly it gets stuck?
    Frank

  • Value binding an object to the request scope

    Hello,
    In one page I have the results conducted from doing a search. Each row displayed in that page represents a user, and there is a link within each row that will facilitate the editing of that user in another page.
    Here is the code for the link in the "results" page:
    <h:column>
         <h:commandLink id="editLink" action="#{pc_Search_user_results.editUser}">
              <h:outputText value="Edit" />
              <f:param name="userId" value="#{user.id}" />
         </h:commandLink>
    </h:column>My second page (that is, the one that will allow edits to be made) expects a "User" instance to be available as part of the request:
    <managed-bean>
      <managed-bean-name>pc_EditUser</managed-bean-name>
      <managed-bean-class>pagecode.jsp.EditUser</managed-bean-class>
         <managed-bean-scope>request</managed-bean-scope>
         <managed-property>
              <description>
                        Should be an instance of the user that was selected from
                        the search results page.
              </description>
              <property-name>user</property-name>
              <value>#{requestScope.user}</value>
         </managed-property>
    </managed-bean>I have that variable defined in the EditUser backing bean for the "edit" page with the appropriate getter/setter. The problem is that instead of getting a "User" instance in the bean, I'm getting a null value for it instead. I'm trying to set the instance in the method associated with the command link in my "results" page. That is, in my SearchUserResults bean, which is the backing bean for my "results" page, I have the following code:
    public String editUser() {
            HtmlCommandLink link = this.getCommandLinkById("editLink");
            String id = null;
            Map map = link.getAttributes();
            List children = link.getChildren();
            for (int i = 0; i < children.size(); i++) {
                if (children.get(i) instanceof UIParameter) {
                    UIParameter parm = (UIParameter) children.get(i);
                    id = (String) parm.getValue();
                    break;
            User user = null;
            Iterator iterator = this.users.iterator();
            while (iterator.hasNext()) {
                user = (User) iterator.next();
                if (id.equals(user.getId())) {
                    break;
            facesContext.getApplication()
                        .createValueBinding("#{requestScope.user}").setValue(
                            facesContext, user);
            return "success";
        }All I want to get in my backing bean for the "edit" page is a valid "User" instance, which should be set when a new instance of EditUser is created per request. Obviously, I'm not understanding what is happening for this simple scenario. Please chime in with suggestions or explanations! Thanks.
    Jeff

    Frank,
    Thanks for your reply.
    Yes. I have dragged the collection called "GetYearsDataRequest" (which has 2 attributes) to the view as to create new form with submit button. Then i dragged the method on the button to bind the method called "GetYears".
    But actually the method GetYears is required complex type "GetYearsDataRequest" as input. I see the collection and the object/complex types are seperated form visual perspective.
    I tried dragging method to create parameter form, but unfortunately it created GetYearsDataRequest as text field rather I would like to see its attribute in the form.
    I am not sure how to bind the attributes to the input object/complex type (GetYearsDataRequest). I think I am missing this step. Pls help me on this.
    I hope I answered to your question.
    Please let me know if you need more info.l
    Thanks!
    Rajasekar.

  • When my friend sends me a video chat request on ichat my cam light turns on, but the cam and the request dont show up. i have a macpro with os x lion

    when my friend sends me a ichat video chat request, my cam light comes on, but my cam, nor hers, nor the request she sent shows up, nor does it make the ringing sound when a call is coming in. also it says she is in another chat but shes not. and when i send the request my cam comes on, but she doesnt get the request. i have a mac pro with os x lion.

    Your HD may be crashed, so you probably should use the oringinal install discs to run Apple Hardware Test in extended mode. If error codes appear this confirms a hardware failure. In addition you cannnot repair the HD using Disk Utility from the startup disk, you have to use the origninal Install discs that shipped with the computer or the most up-to-date version of OS X on a disc that you have.

  • Is there any way to avoid restoring the beans that are in the request scop?

    Hi!
    The problem is that I don't want to have my beans reloaded by the Restore View lifecycle's fase. I CAN'T put them into the session and if I don't do so, every time I click in a commandLink or commandButton for example, the first thing the JSF does is to reconstruct the bean used in the previous view before following to the next view.
    Some properties of the beans are populated through data base access. The problem is that when I just want to go from a page to another I don't want to have this kind of bean reconstructed.
    Any ideas? I'm I doing anything wrong?
    Thank you all!

    In a valuechangelistener you can do this. I've tried it and it works well
         PhaseId phaseId = event.getPhaseId();
              //incorrect phase
              if (phaseId.equals(PhaseId.ANY_PHASE))
              event.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
              event.queue();
              // correct phase
              else if (PhaseId.UPDATE_MODEL_VALUES.equals(event.getPhaseId()))
    load backing bean here

  • Trying to set up mail and iCloud in iPhone4.  It keeps saying verification failed. the request timed out. Not sure what to do,

    Trying to set up mail and iCloud in iPhone4.  It keeps saying verification failed. And the request timed out?  Not sure what to do.  I do have an iCloud account and am able to log on to it on computer and see mail, contacts, etc.  Any ideas?
    thanks for any help

    ausask64 wrote:
    Can't seem to get a connection to internet even thou it tells me i have one. 
    If you see the white WiFi bars in the upper left corner, that simply means that the iPad has detected a WiFi network, and that does not mean that you are connected to the Internet.
    Can you open web sites with Safari?

  • How to get detailStamp working in an af:table when using request scope ?

    <af:table var="row" id="t1" value="#{listUsers.users}" summary="Userlist" binding="#{listUsers.ATable}" [...]
    <af:column sortable="false" headerText="Username" id="c13" filterable="true">
    <af:outputText value="#{row.username}" id="ot13"/>
    </af:column>
    <f:facet name="detailStamp">
    <af:panelFormLayout rows="4" labelWidth="33%" fieldWidth="67%" inlineStyle="width:795px" id="pfl1" labelAlignment="start" >
    <af:group id="g1">
    <af:panelLabelAndMessage id="plamNumber" label="Number" for="number">
    <af:outputText value="#{row.address.number}" id="number"/>
    </af:panelLabelAndMessage>
    I feel there is nothing special with this.
    But I've tested with 2 rows in my table and when I disclose rows, I get random results :
    sometimes I get the details related to the row disclosed, but sometimes I get the details of the other row.
    I've read several posts on the subject but none really helpful.
    Another problem ; I've noticed that when I disclose or close a row, getUsers() is called, this method fetch the data from the DB, any way to prevent it ?
    For the second problem, the solution I see would be to : change scope of listUsers to session instead of request, fetch from the DB only when "refresh", not when "detailStamp",
    but I've no clue on how to actually do the "only when part"
    Thanks in advance,
    JP

    Ok when I change the scope of ListUsers to session it's "ok" since I only load the list from the DB once (just like the demo that does not have this problem since the demo does not use the DB)
    When I change the scope for request and that the page is refreshed then the object ListUsers is "recreated" and the data reloaded : that's the expected behavior
    So I prefer to have the scope sets to request
    The problem is that when a user disclose/close a detailstamp and that the scope is set to request,
    then the data is reloaded from the DB
    because apparently this event acts like a "refresh"
    because this event (disclose/close) cause the destruction of what is in the request scope ...
    That's my understanding, probably few mistakes, I'm beginning with ADF/JSF
    It seems that when I load the data from the DB, it's not always in the same order, causing the problem itself probably, which is not ADF related BUT ;
    what I would like to know is how to (elegantly) prevent the event of "disclose/close" to act like a "refresh" ?
    Because even if I fix the "not ADF related problem" (if there is one), loading the list from the DB each time, appears really useless and the DBA won't like me !
    A solution could be to leave the session scope, but then my question would be ;
    *how to know I've to reload from the DB ?"
    I could just "reload it on page load", seems ok to me but
    I'm not sure it's the best, I would like to have your opinion, I've found this article for the "on page load" part ;
    http://groundside.com/blog/DuncanMills.php?title=adf_executing_code_on_page_load&more=1&c=1&tb=1&pb=1
    Thanks,
    JP

  • Creation of a Managed Bean in Request Scope?

    Is there an easy way to create an instance of a managed bean (configured in faces-config.xml) that was configured to be in the Request scope?
    If a JSP refers to it by id, then it will be there.
    However, when the JSP does not refer to it, it will not be in the request. I find I need to generate it anyway to use it from within another Managed Bean. I can extract out the faces-config information from the application map (available from FacesContext) and build it manually -- but this ties me to a particular JSF implementation (and probably version, too).
    Is there a more standardized way to do this?
    Thanks,
    ken

    BTW -- I mean to do this from within Java code (not jsp), and the page being rendered does not have a direct reference to the request-scoped managed bean via value binding.

  • Communicating between beans in request scope

    I have list.jsp that has a table of items with a link to edit each item like so
    <h:dataTable value="#{list.model}" var="curItem">
        <h:commandLink actionListener="#{item.doActionEdit}" action="edit">
          <h:outputText value="#{curItem.id}"/>
          <f:param name="id" value="#{curItem.id}"/>
        </h:commandLink>
    </h:dataTable>edit is map to item.jsp
    when i click on the link the item bean gets called and doActionEdit sets up the id and fetches data from db but then the bean gets recreated (from scratch and all data is lots id is unset) and it loads item.jsp with and empty bean.
    This only happens when item bean is in request scope, however when it is in session scope it works fine, which brings the question; how can I pass objects to a bean that is in the request scope?
    I have tries to map id of item in faces-config.xml with #{param.id} which works fine if id is passed but fails with a npe when item.jsp loads without id (say I want to create a new item.)
    Please advise me what is the best approach to communicate between beans in request scope, so it will work with and without id being passed.

    here is doActionEdit, basicly it gets the id param and then calls setId which tries to load data from db if id is >0 if that fails or id is <=0 it creates new data object instead.
    when the item bean is in session scope the constructor is called once but if the scope is request it is called twice (first time doActionEdit is called after constructor but the 2nd time only constructor is called and the itemData is empty.
         public void doActionEdit(final ActionEvent event) {
                    int id = 0;
              try {
                   id = Integer.parseInt(FacesUtil.getParameter("id"));
              } catch (Exception e) {
                   e.printStackTrace();
              setId(id);
    private ItemData data = null;
         public void setId(final int id) {
              if (id > 0) {
                   data = DB.getItemData(id); //load data from db
                   if (data == null) {
                        data=new Data();
              else {          
                   data=new Data();
         public Item() {
              data=new Data();
              System.out.println("Loading Item class");
         }

  • DataTable var in request scope?

    Hi all,
    The description for the 'var' attribute of a h:dataTable tag reads:
    "Name of a request-scope attribute under which the model data for the row ... will be exposed."
    So I thought I would be able to access the object set as 'var' in normal JSP expressions and actions:
    <h:dataTable value="#{currentItem.children}" var="item">
      <h:column>
        <h:outputText value="#{item.uri}"/>
        <f:verbatim>${item.uri}</f:verbatim>
      </h:column>
    </h:dataTable>But the ${item.uri} does not evaluate to the same as #{item.uri}. Instead, it is empty, or if 'item' pre-exists in the request scope, it shows that item (and not the one assigned by the dataTable).
    What have I misunderstood?
    Cheers,
    Roger

    Basically:
    JSF<h:dataTable binding="#{myBean.table}" value="#{myBean.list}" var="item">
        <h:column><h:outputText value="#{myBean.value}" /></h:column>
    </h:dataTable>MyBeanprivate HtmlDataTable table;
    private List<Dto> list;
    // + getters + setters
    public String getValue() {
        Dto dto = (Dto) table.getRowData();
        // Do your thing with the current row object.
    }Although I recommend to just add a new property or getter to the DTO. It saves one mapping layer.

  • Storing Objects in Request Scope

    Hello,
    I'm trying to pass an object in the request scope between a JSPDynPage and the associated JSP however the object is always null. If I store it in the session I am able to retrieve it.
    Could anyone assist in how to do this?
    My code is as follows, thanks and regards.
    public class MyClass extends PageProcessorComponent {
      private String redirectToPage = "";
      private static final String INITAL_PAGE = "initialpage.jsp";
      private static final String SECONDARY_PAGE = "secondarypage.jsp";
      private static final String BEAN_ALIAS = "myBean";
      public void doProcessBeforeOutput() throws PageException {
        if (redirectToPage == null || redirectToPage.equals("")) {
          this.setJspName(INITAL_PAGE);
        } else {
          this.setJspName(redirectToPage);
      public void onMyButtonEvent (Event event) {
        redirectToPage = SECONDARY_PAGE;
        MyBeanClass myBean = new MyBeanClass();
        IPortalComponentRequest componentRequest = (IPortalComponentRequest)getRequest();
        componentRequest.putValue(BEAN_ALIAS, myBean);
    secondarypage.jsp:
    <%@ page session = "true"%>
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="request" class="MyBeanClass " />
    <hbj:content id="myContent">
      <hbj:page title="myTitle">
       <hbj:form id="myForm">
         <% if (myBean != null) {
              out.println("null");
            } else {
              out.println("not null");
         %>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    output on the page is always "null" ??

    Hi,
    Thanks for your posts... the null logic was actually a typo.
    I've solved the problem myself - basically I think the <jsp:useBean doesn't work as I expect it (that is automatically obtain the handle to the bean):
    MyDynPage.java:
    package com.my;
    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.enum.*;
    import com.sapportals.htmlb.event.*;
    import com.sapportals.htmlb.page.*;
    import com.sapportals.portal.htmlb.page.*;
    import com.sapportals.portal.prt.component.*;
    public class MyDynPage extends PageProcessorComponent {
      public DynPage getPage(){
        return new MyDynPageDynPage();
      public static class MyDynPageDynPage extends JSPDynPage{
        public void doInitialization(){
        public void doProcessAfterInput() throws PageException {
        public void doProcessBeforeOutput() throws PageException {
              IPortalComponentRequest componentRequest = (IPortalComponentRequest)getRequest();
              componentRequest.putValue("myRequestParam", "My Request Param Value");
              MyBean myBean = new MyBean("My Bean Title Value");          
              componentRequest.putValue("myBean", myBean);
             this.setJspName("myJSP.jsp");
    MyBean.java:
    package com.my;
    import java.io.Serializable;
    public class MyBean implements Serializable {
         private String txtTitle;
         //setters
         public void setTxtTitle(String txtTitle) { this.txtTitle = txtTitle; }
         //getters
         public String getTxtTitle() { return this.txtTitle; }
         public MyBean(String txtTitle) { //constructor
              this.txtTitle = txtTitle;
    myJSP.jsp:
    <%@ page session = "true"%>
    <%@ taglib uri="tagLib" prefix="hbj" %>
    <jsp:useBean id="myBean" scope="request" class="com.my.MyBean" />
    <hbj:content id="myContext" >
      <hbj:page title="PageTitle">
       <hbj:form id="myFormId" >
        <%
               String myRequestParam = (String)componentRequest.getValue("myRequestParam");
              out.println("myRequestParam: " + myRequestParam + "<br>");
              if (myBean == null) {
                   out.println("myBean is null<br>");
              } else {
                   out.println("myBean is not null<br>");
                   out.println(myBean.getTxtTitle() + "<br>");
              com.my.MyBean myOtherBean = (com.my.MyBean) componentRequest.getValue("myBean");
              if (myOtherBean == null) {
                   out.println("myOtherBean is null");
              } else {
                   out.println("myOtherBean is not null<br>");
                   out.println(myOtherBean.getTxtTitle() + "<br>");
        %>
       </hbj:form>
      </hbj:page>
    </hbj:content>
    The output is:
    myRequestParam: My Request Param Value
    <b>myBean is null</b>
    myOtherBean is not null
    My Bean Title Value
    It appears that you can save objects in the request scope however you need to manually retrieve them. I'm pretty sure that this is not the case in other J2EE servers as the <jsp:useBean tag should imply that I want the bean retrieved from the scope automatically or created if it's null.
    However the use of the <jsp:useBean appears to work correctly/as expected when using the session scope.
    Thanks for your assistance.
    DSR

  • How to persist a data in request scope

    Hi All...
    I am using JDeveloper Studio Edition Version 11.1.1.0.2.In my managed bean (backing bean scope), I have a variable say " private loginname;" with a global scope and corresponding getter and setter methods inside the backing bean.How can I persist my data in request scope not using a session variable.
    Thanks in advance
    Dinil Mithra

    Hi all,
    I need to access the data in the request scope( Not in session scope ). ie, after the command button's action or action listener ,I loose the persistence of my variable.But the same time persistence of the textfield exists.I need to implement the persistence like textbox or ADF component
    Thanks for your response
    Dinil Mithra
    Edited by: Dinil Mithra on May 21, 2009 1:25 AM

  • Accessing property of one managed bean to another in request scope

    Right now my applications managed beans are in session scope.
    I want to change them to request scope .But the problem is how to access the bean methods to another if they are in request scope

    Use RequestMap instead of SessionMap.
    Having multiple and independent managed beans in the request scope for 1 request and the need to access the other bean is somewhat odd design however. You may need to rethink about it. For example, add one of the beans as property of the other bean.

Maybe you are looking for

  • How do I add new songs/video to iPhone/iPod without doing a full-sync?

    Hello everyone, My hard drive crashed a few months ago, and I did not have a back up. So I now have this jam packed iPhone and a brand new iTunes library. I recently downloaded some new songs to the library (like that Blackberry commercial 'All You N

  • How can i transfer my whatsapp chat from iphone 3gs to google nexus 5 without losing any data?

    How can i transfer my whatsapp chat from iphone 3gs to google nexus 5 without losing any data? I want to swtich from my iphone to google nexus 5.could anyone help me for this?

  • Payment flow error

    I have one OTC forward derivatives treasury deal, transaction type: buy,  in SPRO, we assign  around 20 Z flow types, among them, Z004 is relevant to CM, and relevant to posting, Z005 is also the same setting, but in FTR_EDIT, payment tab, only Z005

  • Interactive PDFs: checkmark vs radio button

    I am created an Interactive PDF fillable form for a client. They want to use checkmarks for different options that user can choose - however they want the user to only be able to chose ONE of the options. Radio buttons work in this way (if one is sel

  • Dynamic record group not working when apostrophes are used

    Hi Everyone, I have developed a Form for the most part everything is working as expected. However, there is a search functionality that is giving me problems. The issue is that when the user enters search criteria for last_name that has an apostrophe