RE: Help with (1...N) Editing using Ajax?
Laurie, Thanks for your reply. You have nailed the problem! It seems like the 2nd solution is the more elegant one. Are there any reference implementations or examples you could point me to that might show me how to populate the form using JSON data? MG -Original Message- From: news [mailto:[EMAIL PROTECTED] On Behalf Of Laurie Harper Sent: Friday, February 01, 2008 10:45 AM To: user@struts.apache.org Subject: Re: Help with (1...N) Editing using Ajax? The problem is that you're rendering the form before you've stored anything under #session['guide']. I assume when you say you want to 'bind the form to the object' your Ajax request places in the session, you mean you want to populate the form fields with data from that object? That can't work automagically, since the form is just part of the page in the browser and has no knowledge of what might be happening to the session over on the server. There are a couple of approaches you can consider to get this working: 1) instead of rendering the form as part of the initial page load, render it as the result of the Ajax request that loads the data. On the client-side, take that response and render it directly. 2) return the data itself as the result of the Ajax request (in XML or JSON format probably). On the client-side, take that response and use it to populate the form you already have. The key is that the form will not get populated with data just because you made data available after the fact. You either must render the form after the data is available, or perform additional processing to 'push' the data into the form. L. Griffith, Michael * wrote: > In fact, looking at the page source, it appears the expression is never > cooked... > > Here's the input from the rendered page: > value="#session['guide'].shortDescription" > id="updateGuide_#session_'guide'__shortDescription"/> > > -Original Message- > From: Musachy Barroso [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 31, 2008 4:25 PM > To: Struts Users Mailing List > Subject: Re: Help with (1...N) Editing using Ajax? > > so #session['guide'] is not returning anything? > > musachy > > On Jan 31, 2008 5:16 PM, Griffith, Michael * > <[EMAIL PROTECTED]> wrote: >> Hello all, >> >> >> >> I am trying to understand how to present an interface where I allow a >> user to edit a master/detail relationship using an Ajax technique. I > am >> quite new to Struts2, so please forgive the dalliance. >> >> >> >> I have a form that presents the user the ability to edit the master of >> the master/detail, and below the form a list of each of the child >> records. Each child record presents an Ajax enabled link to trigger a >> method on the struts action, where I pick out the child record from > the >> list and put it in the session... >> >> >> >> The link looks like this: >> >> >> >> >> >> > namespace="/datacall" > >> >> > value="#guide.id" /> >> >> >> >> > notifyTopics="updateResult">> value="#guide.shortDescription"/> >> >> >> >> >> >> The method is triggered in the action, and I set the child into my >> request session... >> >> request.getSession().setAttribute("guide", g); >> >> >> >> And I have a form that I'm trying to bind to the object in the > session. >> The form is actually hidden in a div/panel I'm using the YUI to > present >> the form to the user after the round trip to the server. The form > isn't >> bound to the correct variable, because its set via a user interaction >> after the entire page is presented to the user. >> >> The form looks like this: >> >> >> >> >> >> >> >> > name="#session['guide'].shortDescription" /> >> >> > name="#session['guide'].instructions" cols="25" rows="8"/> >> >> >> >> >> >> In Struts 1 I would have gotten a terrible error saying that the bean >> wasn't found. Now the error fails silently. How can I make the form >> somehow bind to the object in the session after the user clicks the >> link? >> >> >> >> Any help would be much appreciated. >> >> >> >> MG >> >> >> >> > > > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with (1...N) Editing using Ajax?
The problem is that you're rendering the form before you've stored anything under #session['guide']. I assume when you say you want to 'bind the form to the object' your Ajax request places in the session, you mean you want to populate the form fields with data from that object? That can't work automagically, since the form is just part of the page in the browser and has no knowledge of what might be happening to the session over on the server. There are a couple of approaches you can consider to get this working: 1) instead of rendering the form as part of the initial page load, render it as the result of the Ajax request that loads the data. On the client-side, take that response and render it directly. 2) return the data itself as the result of the Ajax request (in XML or JSON format probably). On the client-side, take that response and use it to populate the form you already have. The key is that the form will not get populated with data just because you made data available after the fact. You either must render the form after the data is available, or perform additional processing to 'push' the data into the form. L. Griffith, Michael * wrote: In fact, looking at the page source, it appears the expression is never cooked... Here's the input from the rendered page: -Original Message- From: Musachy Barroso [mailto:[EMAIL PROTECTED] Sent: Thursday, January 31, 2008 4:25 PM To: Struts Users Mailing List Subject: Re: Help with (1...N) Editing using Ajax? so #session['guide'] is not returning anything? musachy On Jan 31, 2008 5:16 PM, Griffith, Michael * <[EMAIL PROTECTED]> wrote: Hello all, I am trying to understand how to present an interface where I allow a user to edit a master/detail relationship using an Ajax technique. I am quite new to Struts2, so please forgive the dalliance. I have a form that presents the user the ability to edit the master of the master/detail, and below the form a list of each of the child records. Each child record presents an Ajax enabled link to trigger a method on the struts action, where I pick out the child record from the list and put it in the session... The link looks like this: The method is triggered in the action, and I set the child into my request session... request.getSession().setAttribute("guide", g); And I have a form that I'm trying to bind to the object in the session. The form is actually hidden in a div/panel I'm using the YUI to present the form to the user after the round trip to the server. The form isn't bound to the correct variable, because its set via a user interaction after the entire page is presented to the user. The form looks like this: In Struts 1 I would have gotten a terrible error saying that the bean wasn't found. Now the error fails silently. How can I make the form somehow bind to the object in the session after the user clicks the link? Any help would be much appreciated. MG - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help with (1...N) Editing using Ajax?
In fact, looking at the page source, it appears the expression is never cooked... Here's the input from the rendered page: -Original Message- From: Musachy Barroso [mailto:[EMAIL PROTECTED] Sent: Thursday, January 31, 2008 4:25 PM To: Struts Users Mailing List Subject: Re: Help with (1...N) Editing using Ajax? so #session['guide'] is not returning anything? musachy On Jan 31, 2008 5:16 PM, Griffith, Michael * <[EMAIL PROTECTED]> wrote: > Hello all, > > > > I am trying to understand how to present an interface where I allow a > user to edit a master/detail relationship using an Ajax technique. I am > quite new to Struts2, so please forgive the dalliance. > > > > I have a form that presents the user the ability to edit the master of > the master/detail, and below the form a list of each of the child > records. Each child record presents an Ajax enabled link to trigger a > method on the struts action, where I pick out the child record from the > list and put it in the session... > > > > The link looks like this: > > > > > > namespace="/datacall" > > > value="#guide.id" /> > > > > notifyTopics="updateResult"> value="#guide.shortDescription"/> > > > > > > The method is triggered in the action, and I set the child into my > request session... > > request.getSession().setAttribute("guide", g); > > > > And I have a form that I'm trying to bind to the object in the session. > The form is actually hidden in a div/panel I'm using the YUI to present > the form to the user after the round trip to the server. The form isn't > bound to the correct variable, because its set via a user interaction > after the entire page is presented to the user. > > The form looks like this: > > > > > > > > name="#session['guide'].shortDescription" /> > > name="#session['guide'].instructions" cols="25" rows="8"/> > > > > > > In Struts 1 I would have gotten a terrible error saying that the bean > wasn't found. Now the error fails silently. How can I make the form > somehow bind to the object in the session after the user clicks the > link? > > > > Any help would be much appreciated. > > > > MG > > > > -- "Hey you! Would you help me to carry the stone?" Pink Floyd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help with (1...N) Editing using Ajax?
Nope, nothing. If I bind my form to #guide. I find the first or last item in the Collection that belongs to the parent when the list was iterated over. Maybe there is a better way to specify how to bind the property to the struts control? Maybe something like: But how would I specify the item index in the collection? Cheers! MG -Original Message- From: Musachy Barroso [mailto:[EMAIL PROTECTED] Sent: Thursday, January 31, 2008 4:25 PM To: Struts Users Mailing List Subject: Re: Help with (1...N) Editing using Ajax? so #session['guide'] is not returning anything? musachy On Jan 31, 2008 5:16 PM, Griffith, Michael * <[EMAIL PROTECTED]> wrote: > Hello all, > > > > I am trying to understand how to present an interface where I allow a > user to edit a master/detail relationship using an Ajax technique. I am > quite new to Struts2, so please forgive the dalliance. > > > > I have a form that presents the user the ability to edit the master of > the master/detail, and below the form a list of each of the child > records. Each child record presents an Ajax enabled link to trigger a > method on the struts action, where I pick out the child record from the > list and put it in the session... > > > > The link looks like this: > > > > > > namespace="/datacall" > > > value="#guide.id" /> > > > > notifyTopics="updateResult"> value="#guide.shortDescription"/> > > > > > > The method is triggered in the action, and I set the child into my > request session... > > request.getSession().setAttribute("guide", g); > > > > And I have a form that I'm trying to bind to the object in the session. > The form is actually hidden in a div/panel I'm using the YUI to present > the form to the user after the round trip to the server. The form isn't > bound to the correct variable, because its set via a user interaction > after the entire page is presented to the user. > > The form looks like this: > > > > > > > > name="#session['guide'].shortDescription" /> > > name="#session['guide'].instructions" cols="25" rows="8"/> > > > > > > In Struts 1 I would have gotten a terrible error saying that the bean > wasn't found. Now the error fails silently. How can I make the form > somehow bind to the object in the session after the user clicks the > link? > > > > Any help would be much appreciated. > > > > MG > > > > -- "Hey you! Would you help me to carry the stone?" Pink Floyd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Help with (1...N) Editing using Ajax?
so #session['guide'] is not returning anything? musachy On Jan 31, 2008 5:16 PM, Griffith, Michael * <[EMAIL PROTECTED]> wrote: > Hello all, > > > > I am trying to understand how to present an interface where I allow a > user to edit a master/detail relationship using an Ajax technique. I am > quite new to Struts2, so please forgive the dalliance. > > > > I have a form that presents the user the ability to edit the master of > the master/detail, and below the form a list of each of the child > records. Each child record presents an Ajax enabled link to trigger a > method on the struts action, where I pick out the child record from the > list and put it in the session... > > > > The link looks like this: > > > > > > namespace="/datacall" > > > value="#guide.id" /> > > > > notifyTopics="updateResult"> value="#guide.shortDescription"/> > > > > > > The method is triggered in the action, and I set the child into my > request session... > > request.getSession().setAttribute("guide", g); > > > > And I have a form that I'm trying to bind to the object in the session. > The form is actually hidden in a div/panel I'm using the YUI to present > the form to the user after the round trip to the server. The form isn't > bound to the correct variable, because its set via a user interaction > after the entire page is presented to the user. > > The form looks like this: > > > > > > > > name="#session['guide'].shortDescription" /> > > name="#session['guide'].instructions" cols="25" rows="8"/> > > > > > > In Struts 1 I would have gotten a terrible error saying that the bean > wasn't found. Now the error fails silently. How can I make the form > somehow bind to the object in the session after the user clicks the > link? > > > > Any help would be much appreciated. > > > > MG > > > > -- "Hey you! Would you help me to carry the stone?" Pink Floyd - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]