English 中文(简体)
JQuery, JSF and a4j:commandLink
原标题:

I have a problem with using jQuery Dialog and Ajax submit in JSF. I have the following code for displaying Dialog windows:

                <script type="text/javascript"> 
                        jQuery(function(){ 
                                // Dialog 
                                jQuery( #dialog ).dialog({ 
                                        dialogClass:  alert , 
                                        autoOpen: false, 
                                        width: 300, 
                                        height: 150, 
                                        modal: true, 
                                        resizable: false, 
                                        overlay: { 
                                                backgroundColor:  #000 , 
                                                opacity: 0.5 
                                        }, 
                                        buttons: { 
                                                "Ok":  function() { 
                                                        jQuery(this).dialog("close"); 
                                                        return true; 
                                                }, 
                                                "Cancel": function() { 
                                                        jQuery(this).dialog("close"); 
                                                        return false; 
                                                } 
                                        } 
                                }); 

                                // Dialog Link 
                                jQuery( #dialog_link ).click(function(){ 
                                        jQuery( #dialog ).dialog( open ); 
                                        return false; 
                                }) 
                                .hover( 
                                        function() { jQuery(this).addClass( ui-hover-state ); }, 
                                        function() { jQuery(this).removeClass( ui-hover-state ); } 
                                ); 

                        }); 
                </script> 
It works as it should - it displays box when link is clicked. 
Now, I have something like this, for deleting something: 
<a4j:commandLink 
        actionListener="#some.action" 
        reRender="something" 
        onclick="if(!jQuery( #dialog ).dialog( open )){return false}" 

ok, this commandLink is rendered as follows: 
<a href="#" 
        id="some:long:id:j_id338" 
        name="formName:something:j_id338" 
        onclick="if(!jQuery( #dialog ).dialog( open )){return 
false};A4J.AJAX.Submit( something:something ); 
        return false;" 
>drop</a> 

now, after displaying the dialog box, the A4j.AJAX.Submit(..) is executed, is there anyway, that I can for example, pass the whole A4J.AJAX.Submit(...) to "dialog" and execute it from "ok" option? I simply need to execute submit if and only if user clicks OK. Thank you for help JQ

最佳回答

You can define:

<a4j:jsFunction name="okClicked"
    actionListener="#{some.action}" 
    reRender="something" />

And call it in the OK function, like:

"Ok": function() { 
    jQuery(this).dialog("close");
    okClicked();
    return true; 
}
问题回答

暂无回答




相关问题
JSF a4j:support with h:selectManyCheckbox

I m having trouble with a JSF selectManyCheckbox and A4J support. The purpose is to run some action when a checkbox is selected. This works perfectly in Firefox. Yet, when testing in any IE (ie6 / ie7 ...

Mojarra for JSF Encoding

Can anyone teach me how to use mojarra to encode my JSF files. I downloaded mojarra and expected some kind of jar but what i had downloaded was a folder of files i don t know what to do with

如何拦截要求终止?

在共同基金中,如果用户要求终止,就需要采取一些行动。 我需要某种拦截器,但我不知道如何这样做。 我需要帮助。 增 编

ICEFaces inputFile getting the file content without upload

Is there any way of just getting the content of the browsed file without any upload/file transfer operations? I currently use ICEFaces inputFile component but I do not need the default uploading ...

Weird behaviour of h:commandLink action (MethodExpression)

I have two JSPs where I am displaying some info from database in a h:dataTable. One of them is showing all the info, and one of them user specifically. I have showXML.jsp that shows the "XML" column ...

How to correctly use ResultSet with h:dataTable

The problem is, that after displaying the ResultSet with <h:dataTable>, the connection is left open. If I close it, it closes the ResultSet too. I m thinking about copying the ResultSet data ...

热门标签