I'm sorry I sent my message to the wrong list ...
I just sent it to the user list ;)

2007/4/26, Olivier THIERRY <[EMAIL PROTECTED]>:

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

Reply via email to