Invoke dialog by keyboard

UI Components for JSF
Post Reply
User avatar
ITReppert
Posts: 57
Joined: 07 Feb 2011, 19:43

02 May 2012, 15:24

Hi,

I need to invoke a dialog by pressing a key. Is this possible ?
I also want to invoke the roweditor in a datatable by pressing a key.

Any ideas ?

Regards,
Holger
// Netbeans 7.2 // Glassfish 3.1.2 // Windows 7 (64 bit) // FireFox // PrimeFaces 3.4.2

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

02 May 2012, 15:28

Easy, see hotkey component.

User avatar
ITReppert
Posts: 57
Joined: 07 Feb 2011, 19:43

02 May 2012, 15:49

Yeah,

found it :
<p:hotkey bind="ctrl+e" handler="customerDetailDialog.show();"/>

But how to invoke the roweditor ?

regards,
Holger
// Netbeans 7.2 // Glassfish 3.1.2 // Windows 7 (64 bit) // FireFox // PrimeFaces 3.4.2

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

03 May 2012, 16:01

ITReppert wrote:Yeah,

found it :
<p:hotkey bind="ctrl+e" handler="customerDetailDialog.show();"/>

But how to invoke the roweditor ?

regards,
Holger
Well first of all you are going to have to work out how to select a row you want and then create a handler that invokes the rowEditor for the currently selected row.
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

User avatar
ITReppert
Posts: 57
Joined: 07 Feb 2011, 19:43

03 May 2012, 16:32

Hi,
Well first of all you are going to have to work out how to select a row you want and then create a handler that invokes the rowEditor for the currently selected row.
that's true !

It should always be the actual selected row. JQuery/JScript should know which one is selected, but I don't know,
how to invoke the rowEditor. I stumbled through the Javascript, but hadn't the time to go in deeper. :oops:
Any suggestions ?

Regards,
Holger

Edit :
I found this in datable.js

Code: Select all

    setupCellEditorEvents: function() {
        var _self = this,
        rowEditors = $(this.jqId + ' tbody.ui-datatable-data > tr > td span.ui-row-editor');

        rowEditors.find('span.ui-icon-pencil').die().live('click', function() {
            _self.showEditors(this);
        });

        rowEditors.find('span.ui-icon-check').die().live('click', function() {
            _self.saveRowEdit(this);
        });

        rowEditors.find('span.ui-icon-close').die().live('click', function() {
            _self.cancelRowEdit(this);
        }); 
    },
but I don't know how to invoke

Code: Select all

 _self.showEditors(this);
from <p:hotkey>
// Netbeans 7.2 // Glassfish 3.1.2 // Windows 7 (64 bit) // FireFox // PrimeFaces 3.4.2

User avatar
ITReppert
Posts: 57
Joined: 07 Feb 2011, 19:43

03 May 2012, 18:05

So I did it like that :

Code: Select all

        <script type="text/javascript">
            function clickSelectedRowPencil(){
                jQuery('.ui-state-highlight').find('.ui-icon-pencil').click();
            }
        </script>
Which means get css class ui-state-highlight (works with a single selection!) and find within the class ui-icon-pencil and click it.

All you need to do now is :

Code: Select all

<p:hotkey bind="ctrl+e" handler="clickSelectedRowPencil();"/> 
or

Code: Select all

<p:hotkey bind="ctrl+e" handler="jQuery('.ui-state-highlight').find('.ui-icon-pencil').click();"/> 
// Netbeans 7.2 // Glassfish 3.1.2 // Windows 7 (64 bit) // FireFox // PrimeFaces 3.4.2

User avatar
ITReppert
Posts: 57
Joined: 07 Feb 2011, 19:43

03 May 2012, 22:02

Nice try, but it doesn't really work, because the pencil gets clicked a lot ...................
And I don't know why ........
// Netbeans 7.2 // Glassfish 3.1.2 // Windows 7 (64 bit) // FireFox // PrimeFaces 3.4.2

User avatar
ITReppert
Posts: 57
Joined: 07 Feb 2011, 19:43

04 May 2012, 00:05

Soooooo,

got it working.

Code: Select all

 <p:hotkey bind="ctrl+f1" handler="clickSelectedRowPencil();" /> 
shouldn't be inside a <h:form> or inside a tag that gets updated ......

So, the above solution works.

Regards,
Holger
// Netbeans 7.2 // Glassfish 3.1.2 // Windows 7 (64 bit) // FireFox // PrimeFaces 3.4.2

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 24 guests