Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Passing parameter to a4j:function

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>
like image 220
Gadolin Avatar asked Sep 07 '26 05:09

Gadolin


1 Answers

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

like image 153
Ununoctium Avatar answered Sep 09 '26 19:09

Ununoctium



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!