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:
<input type="text" name="#session['guide'].shortDescription"
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:



            <s:iterator id="guide" value="guides">

                        <s:url id="editGuide" action="getGuide"
namespace="/datacall" >

                                    <s:param name="gid"
value="#guide.id" />

                        </s:url>

                        <s:a theme="ajax" href="%{editGuide}"
notifyTopics="updateResult"><s:property
value="#guide.shortDescription"/></s:a> <br/>

            </s:iterator>



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:



<s:form theme="ajax" action="updateGuide" method="post">

            <s:hidden name="#session['guide'].id" />

            <s:textfield key="guide.shortDescription"
name="#session['guide'].shortDescription" />

            <s:textarea key="guide.instructions"
name="#session['guide'].instructions" cols="25" rows="8"/>

</s:form>



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]

Reply via email to