InPlaceEditor callback option.

52 views
Skip to first unread message

Iván Sixto López

unread,
Dec 26, 2014, 12:05:45 PM12/26/14
to tapestry...@googlegroups.com
Hi, I'm implementing an ajax datatable with inplace editor components.


 <t:jquery.datatable class="datatable_ajax"  t:inplace="true" t:add="options" t:id="datatableAjax"  t:mode="true" t:rowIndex="indexBis" t:model="model" t:source="subjects" rowsPerPage="5"  t:options="options" t:row="subject">

       
<p:nameCell>
           
<div t:id="subjectname" t:type="jquery/inPlaceEditor" t:options="editorParams" value="subject?.name" t:context="subject?.subjectid" />
       
</p:nameCell>
       
<p:yearCell><div t:id="subjectyear" t:type="jquery/inPlaceEditor" t:options="editorParams" value="subject?.year" t:context="subject?.subjectid"/></p:yearCell>
       
<p:titulationCell><div t:id="subjecttitulation" t:options="editorParams" t:type="jquery/inPlaceEditor" value="subject?.titulation" t:context="subject?.subjectid"/></p:titulationCell>
       
<p:optionsCell>
           
<div id="minioptions" ><span><t:actionlink t:id="deleteSubject" context="subject?.subjectid"><img src="${context:userpanellayout/images/delete-icon.png}"/></t:actionlink> <t:actionlink t:id="subjectDetail" context="subject?.subjectid"><img src="${context:userpanellayout/images/delete-icon.png}"/></t:actionlink></span></div>
       
</p:optionsCell>
 
</t:jquery.datatable>


In java class I've got getEditorParams to read InplaceEditor component options:

public JSONObject getEditorParams() {

 
JSONObject params=new JSONObject();
 
params.put("callback", new JSONLiteral("function(value,settings)" +"{ console.output('dddd'); }"));
 
return params;
}

If I try to load the web app, I've got the alert: "JSON data from the server could not be parsed"

So, I guess there is something wrong with the JSONLiteral... If I send String instead, callback function is not read so it can't be called....

Sorry for y English... Any help? 

Thanks guys!

Emmanuel DEMEY

unread,
Dec 31, 2014, 4:13:50 AM12/31/14
to tapestry...@googlegroups.com
You should use JavaScript closure maybe. You can find an example in the demo page (from another component lib) : 


Have a look to the gridComplete property of the JSON Object. 

Regards

Manu

Iván Sixto López

unread,
Jan 9, 2015, 8:13:14 AM1/9/15
to tapestry...@googlegroups.com
Sorry for late response, 

I've tried:



public JSONObject getEditorParams() {
 
 
JSONObject params=new JSONObject();

 
params.put("callback", new JSONLiteral(String.format("reloadFunc()")));
 
return params;
 
}
and


function reloadFunc(){
 
var func = function(){
 console
.output('dddd');
 
}
 
return func;
}

And same result... The only thing I wanna do is to be able to execute a javascript function when submitting the Inplaceeditor... 

Iván Sixto López

unread,
Jan 11, 2015, 8:16:12 PM1/11/15
to tapestry...@googlegroups.com
Ok, just to clarify:

I've made the

@Import(library = { "context:static/js/table.js"})


And table.js content is: 

function reloadFunc(){
 
var func = function(){
 console
.output('dddd');
 
}
 
return func;
}

I think I'm getting crazy with this... And, since I think something is going wrong with JSON validator (when trying to validate function not being string)... Is there any way to disable JSON validator on tapestry5-jquery? Nothing more comes to my poor mind... 

Thanks again guys. :)

Emmanuel DEMEY

unread,
Jan 14, 2015, 5:35:59 AM1/14/15
to tapestry...@googlegroups.com
Hi, 

I do not have all your java class, but you should not specify the callback jQuery parameter at this level. 


public JSONObject getEditorParams() {
 
 
JSONObject params=new JSONObject();

 JSONObject options = new JSONObject();
 
options.put("callback", new JSONLiteral(String.format("reloadFunc()")));

 params.put("options", options);
 
return params;

Iván Sixto López

unread,
Jan 14, 2015, 5:57:53 AM1/14/15
to tapestry...@googlegroups.com
Hi Emmanuel, 

Thanks for your anwser... But, If I should not specify callback parameter as t:options in <div t:type="jquery/inPlaceEditor"> ...

Then, where should I specify it? 

Thanks!

Emmanuel DEMEY

unread,
Feb 16, 2015, 4:05:55 AM2/16/15
to tapestry...@googlegroups.com
In the options property of the JSONObject : 

public JSONObject getEditorParams() {
 
 
JSONObject params=new JSONObject();

 --> JSONObject options = new JSONObject();
 --> 
options.put("callback", new JSONLiteral(String.format("reloadFunc()")));

 --> params.put("options", options);
 
return params;
 
}

Alexander Sommer

unread,
Feb 16, 2015, 4:07:43 AM2/16/15
to tapestry...@googlegroups.com
Dear Tapestry5 Developer, 

It is true that Tapestry 5.4 will come with a more flexible way to support JQuery Mobile in be able to replace Prototype?

If so, I also hope that there will come examples quickly. 

thank you
alex

--
You received this message because you are subscribed to the Google Groups "tapestry5-jquery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tapestry5-jque...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages