struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Musachy Barroso" <musa...@gmail.com>
Subject Re: How to fill a div from an Ajax call when a onchange event is fired ?
Date Thu, 26 Apr 2007 16:05:59 GMT
yes, all the values will be sent, but there is a "formFilter" attribute
where you can specify a function that will be called for each element, and
you just need to return true, for the ones that you want to be submitted.
The function has one parameter, which will be the element.

musachy

On 4/26/07, Olivier THIERRY <olivier.thierry@gmail.com> wrote:
>
> 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 <musachy@gmail.com>:
> >
> > 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 <olivier.thierry@gmail.com> 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
> >
>



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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message