You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "lidijaldo ." <li...@gmail.com> on 2013/11/04 06:35:27 UTC

Re: Simply refresh a zone after datatable record edit - not so simple?

Bugger :-/. I didn't know that, thanks.

My current JSON response is:

{
  "row" : {
    "validTo" : "30-11-2013",
    "id" : 19,
    "imageFilename" : "",
    "title" : "Jesen",
    "url2" : "http://blah.com",
    "validFrom" : "30-10-2013",
    "active" : true,
    "url" : "http://www.blah2.com"
  }
}

This is the data for the given object / row in the datatable.

I tried to do as you and Nathan suggested - changed the method to return
void. If I don't return StreamResponse, I get the following JavaScript
alert:
"DataTables warning (table id = 'najdiEdiDataTable'): Requested unknown
parameter 'id' from the data source for row 0"

In Firebug it seems I get a response for the zone though:
{

  "zones" : {    "boxZone" : "\nMon Nov 04 06:20:47 CET 2013\n"  }}

But the zone doesn't refresh. Maybe because of the Javascript alert?

Is there another way to refresh a zone after I edit a row in a datatable?

Regards,
Lidija

On Wed, Oct 30, 2013 at 4:43 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Wed, 30 Oct 2013 11:49:33 -0200, lidijaldo . <li...@gmail.com>
> wrote:
>
>  @OnEvent(component = DATATABLE_ID, value = EVENT_EDITOR_EDIT)
>>     public Object edit(@RequestParameter("action") String action) throws
>> Exception {
>>
>>         .... // edit and save object
>>
>>         // refresh module box
>>         logger.debug("request.isXHR() = " + request.isXHR());      // this
>> outputs "true"
>>     ajaxResponseRenderer.addRender("boxZone", boxZone);
>>
>>         return new TextStreamResponse("application/json",
>> response.toString());
>> }
>>
>
> You either use AjaxResponseRenderer.addRender() or return a
> StreamResponse, but not both at the same time. It's like trying to give two
> answers for the same requests. As you want to refresh a zone, you shouldn't
> return a StreamResponse.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Simply refresh a zone after datatable record edit - not so simple?

Posted by "lidijaldo ." <li...@gmail.com>.
Each of the row in my datatable represents an object with an image that
should be displayed in a zone. The zone should refresh after each row
change because the image for that object can be changed.

What I did was simply refresh the whole page with JavaScript after the row
was successfully edited (and file uploaded through editor). There's
probably some more elegant solution but it's ok for what I need:

So I'm calling location.reload(); on editor's onSubmitSuccess. If success,
location.reload() then reloads the whole page and object in the zone is
displayed ok.

Regards,
Lidija