Hello,

I am a certified newcomer to all of this.
Searching on google for ajax.js gives me multiple results which all look like 
different libraries. Does Tapestry provide an ajax.js library? Does JQuery 
provide an ajax.js library? What other ajax.js library should I use to generate 
my POST? Is the POST request I generated buggy? How would using the other 
library help me?

Regards,
Daniel P.

-----Ursprüngliche Nachricht-----
Von: Chris Poulsen [mailto:mailingl...@nesluop.dk] 
Gesendet: Mittwoch, 27. Mai 2015 11:19
An: Tapestry users
Betreff: Re: AW: AW: Adding JS to my component combined with using t:If

take a look at the ajax.js module and see if you can use that instead of 
generating your own $.post

On Wed, May 27, 2015 at 10:45 AM, Poggenpohl, Daniel < 
daniel.poggenp...@isst.fraunhofer.de> wrote:

> Hello again,
>
> I have generated the event urls and given them to my editor 
> initialization script.
> An excerpt:
> setup   : function(editor) {
>         editor.addButton('testButton', {
>                 text: 'Test Button',
>                 icon: false,
>                 onclick: function() {
>                         var sentData = {paragraphContent :
> tinymce.activeEditor.getContent()};
>                         $.post(
>                                 jsonObject.saveUrl,
>                                 sentData,
>                                 function(data, status) {
>                                         tinymce.remove(jsonObject.elemId);
>                                 }
>                         );
>                 }
>         });
> }
>
> When the user clicks the test button, an AJAX request containing the 
> content of the editor is sent to the server. After receiving the 
> response the editor should be removed from the DOM.
>
> The handler side:
> void onSaveWork(@RequestParameter(value="paragraphContent") final 
> String
> paragraphContent) {
>         showEditor = false;
>         ajaxResponseRenderer.addRender(chapterContentZone);
> }
>
> To be simple at first, the event handler only sets showEditor and 
> queues a render of the zone containing the editor. So the only thing 
> that should be happening is that the div displaying the read-only 
> content should reappear, which it doesn't.
>
> I guess this is because the response isn't handled automatically and I 
> have to replace a client-side DOM element with the "data" content of 
> the response. Is it because I use a self-written javascript and don't 
> rely fully on Tapestry here? Should I use some functions of tapestry.js?
>
> Am I doing something wrong here or am I on the right track?
>
> Regards,
> Daniel P.
>
> -----Ursprüngliche Nachricht-----
> Von: Poggenpohl, Daniel
> Gesendet: Mittwoch, 27. Mai 2015 09:02
> An: Tapestry users
> Betreff: AW: AW: AW: Adding JS to my component combined with using 
> t:If
>
> Hi,
>
> thank you for helping me. Again I had wording issues, it seems.
> I did know that event handling methods on Tapestry pages and 
> components are written manually.
> I just wrote "event handlers" because I thought there was something in 
> between the handler methods and the Eventlinks that was generated when 
> an Eventlink is created. Now I have realized that creating an 
> Eventlink amounts to generating the markup for a link with the URL 
> containing the event name. When you then send a request with this URL, 
> Tapestry sees the event and looks for an appropriately named handler in the 
> page/component.
> I had just thought there was more to it.
>
> As you say in your advice, I expected too much and am now using the 
> method of generating an Eventlink request URL that I give to the 
> tinyMCE editor so that the appropriate request is made at the expected 
> time. I think that is the way to go.
>
> I also thought that JavaScript events, HTML DOM events and Tapestry 
> Component Events were the same before.
>
> Regards,
> Daniel P.
>
> -----Ursprüngliche Nachricht-----
> Von: Thiago H de Paula Figueiredo [mailto:thiag...@gmail.com]
> Gesendet: Dienstag, 26. Mai 2015 20:58
> An: Tapestry users
> Betreff: Re: AW: AW: Adding JS to my component combined with using 
> t:If
>
> On Tue, 26 May 2015 11:49:20 -0300, Poggenpohl, Daniel < 
> daniel.poggenp...@isst.fraunhofer.de> wrote:
>
> > Hi again,
>
> Hi!
>
> > Jquery can define arbitrary events that can be triggered. I thought 
> > I could raise a JS event and handle it via "onEVENTNAME" on the 
> > Tapestry component side. But of course that doesn't work, probably 
> > because no event handlers are generated because no corresponding 
> > eventlink is created.
>
> Event handlers aren't generated at all by Tapestry. You declare them 
> by using @OnEvent or using a naming convention. You just cannot 
> trigger a JS event and expect it to magically trigger a server-side event.
>
> Tapestry doesn't need an EventLink or ActionLink to be able to trigger 
> an event handler method in the server-side. You can create your own 
> events and their URLs by using ComponentResources.createEventLink(). 
> With the URL generated by that method, you can invoke them using AJAX in JS.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer 
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to