Thanks a lot, I can call my action now.

One more question ...
When I set the formId attribute for the div, does it mean that all values in
the form will be sent to my action ?
If it is the case, is there a way to send only the value of my textfield ?

Olivier

2007/4/26, Musachy Barroso <[EMAIL PROTECTED]>:

I think it will be easier (and work) like this:

1. set href in your div, pointing to your action
2. set formId in your div pointing to the form that has the text field
3. add listenTopic to your div
4. publish the topic of 3. when the user types in the textbox

musachy

On 4/26/07, Olivier THIERRY <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I used to use Struts 1.x and I just begin to use Struts 2.x
> I am very interested with the Ajax feature, but I can't make it work ...
>
> What I need to do looks very classical to me :
> - The user types an employee code in a text box
> - When the onchange event is fired, I call a Struts action with Ajax
> - This action retrieves the firstname and the name of the employee. I
want
> these informations to be displayed into a div.
>
> I found a similar example in the Struts documentation (bottom of this
page
> :
> http://struts.apache.org/2.0.6/docs/ajax-div-template.html ), but I
can't
> make it work ...
>
> When the onchange event is fired, I have the following Javascript error
:
>
> FATAL exception raised: TypeError: infosDemandeurDiv has no properties
>
> Could someone tell me what I did wrong, or if there is an easier method
to
> do what I want ?
>
> Here is the head section of my jsp :
>
> <head>
>     <title>Demande d'absence</title>
>     <s:head theme="ajax" debug="true" />
>     <script type="text/javascript">
>         function updateInfosDemandeur(matricule) {
>            var infosDemandeurDiv = window['infosDemandeur'];
>            infosDemandeurDiv.href =
> '/../employes/getInfosEmploye.action?matricule='
> + matricule;
>            infosDemandeurDiv.bind ();
>         }
>         dojo.event.topic.getTopic
> ("updateInfosDemandeurTopic").subscribe(null,
> "updateInfosDemandeur");
>     </script>
> </head>
>
> ... and an extract of the form section ...
>
>     <s:form action="submitCreerDemandeAbsence">
>         <s:textfield     name="demandeAbsence.matriculeDemandeur"
>                         label="Matricule"
>                         onchange="
> dojo.event.topic.publish('updateInfosDemandeurTopic',
> this.value);" />
>         <s:div id="infosDemandeur" theme="ajax" loadingText="Loading
> ..."></s:div>
>         <s:submit type="button" theme="ajax" />
>     </s:form>
>
> Thanks in advance
>
> Olivier
>



--
"Hey you! Would you help me to carry the stone?" Pink Floyd

Reply via email to