最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Passing parameter to a4j:function - Stack Overflow

programmeradmin3浏览0评论

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"
        onplete="" reRender="appexplrtable">         
<a4j:actionparam name="newCategory" />
</a4j:jsFunction>

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"
        onplete="" reRender="appexplrtable">         
<a4j:actionparam name="newCategory" />
</a4j:jsFunction>
Share Improve this question edited May 8, 2011 at 20:58 BalusC 1.1m376 gold badges3.7k silver badges3.6k bronze badges asked May 8, 2011 at 17:20 GadolinGadolin 2,6863 gold badges28 silver badges34 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You need to assign the parameter to set.

<a4j:jsFunction name="categoryChanged"
        action="#{appexplorerbean.categoryChanged(newCategory)}" limitToList="true"
        onplete="" reRender="appexplrtable">         
    <a4j:actionparam name="newCategory" assignTo="#{newCategory} />
</a4j:jsFunction>

or directly set the value.

<a4j:jsFunction name="categoryChanged"
            action="#{appexplorerbean.categoryChanged}" limitToList="true"
            onplete="" reRender="appexplrtable">        
    <a4j:actionparam name="newCategory" assignTo="#{appexplorerbean.newCategory} />
</a4j:jsFunction>

Hope it still helps

发布评论

评论列表(0)

  1. 暂无评论