Reputation: 2686
How can I pass parameter to a4j:jsFunction from javascript, I want to call categoryChanged and whatever I put there - even explicit String, parameter is not visible on bean side.
Here is js code:
$(function() {
$( "#resizable" ).resizable();
$( "#selectable" ).selectable({stop: function(event, ui) {
$( ".ui-selected", this ).each(function() {
var index = $( "#selectable li" ).index( this );
categoryChanged("Test String");
categoryChanged(this);
categoryChanged(ui.id);
categoryChanged($( "#selectable li" ).value(this));
});
// ajax call to render the content
}});
$("#menu").buttonset();
});
and a4j function definition:
<a4j:jsFunction name="categoryChanged"
action="#{appexplorerbean.categoryChanged}" limitToList="true"
oncomplete="" reRender="appexplrtable">
<a4j:actionparam name="newCategory" />
</a4j:jsFunction>
Upvotes: 3
Views: 6230
Reputation: 51
You need to assign the parameter to set.
<a4j:jsFunction name="categoryChanged"
action="#{appexplorerbean.categoryChanged(newCategory)}" limitToList="true"
oncomplete="" reRender="appexplrtable">
<a4j:actionparam name="newCategory" assignTo="#{newCategory} />
</a4j:jsFunction>
or directly set the value.
<a4j:jsFunction name="categoryChanged"
action="#{appexplorerbean.categoryChanged}" limitToList="true"
oncomplete="" reRender="appexplrtable">
<a4j:actionparam name="newCategory" assignTo="#{appexplorerbean.newCategory} />
</a4j:jsFunction>
Hope it still helps
Upvotes: 5