Rectangle 27 0

You can access jQuery Methods like click over the jq attribute on most Primefaces components. If you change your code like this

<p:hotkey bind="alt+n" handler="varCommandButtonNovo.jq.click()" />

jsf - Using handler with p:hotkey and p:commandButton in Primefaces - ...

jsf primefaces hotkeys
Rectangle 27 0

Use the RequestContext object to execute javascript from the server side. To use this:

Define a method in your backing bean, in which you'll make use of the RequestContext object

public void doJs() {
    RequestContext ctx = RequestContext.getCurrentInstance();
    context.execute("progress.cancel();");
}
  • Set this method in the listener attribute of the <p:ajax/> <p:progressBar value="#{myTask.progress}" labelTemplate="{value}%" ajax="true" widgetVar="progress"> <p:ajax event="complete" listener="#{theBean.doJs}"/> </p:progressBar>

EDIT: To perform the execute after every ajax update, the setup is a little different:

Add the interval attribute to your progress bar to introduce a better controlled polling mechanism

Add an <f:event/> to hook into the page lifecycle of the component and perform your server-side update from there. I'm going to recommend the PostValidateEvent event

<p:progressBar value="#{myTask.progress}" labelTemplate="{value}%" ajax="true"
    widgetVar="progress" interval="3000">
    <f:event type="postValidate" listener="#{theBean.doJs}" />
</p:progressBar>

Proper syntax is <f:event listener="#{myTask.doJS}" type="postValidate"/> but it works now. While I dont like putting any JS code on backend this seems like the only workable solution. Thanks!

@rootkit, thanks, oversight on my part. Kinda typed that in a hurry

jsf - How to implement update handler for Primefaces progressBar? - St...

jsf jsf-2 primefaces
Rectangle 27 0

<filter>
  <filter-name>PrimeFaces FileUpload Filter</filter-name>
  <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>PrimeFaces FileUpload Filter</filter-name>
  <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

And you don't need those commons-io libs on WEB-INF\lib since you are using PF5 already. Remove them.

jsf - Primefaces 5 fileUpload handler not called - Stack Overflow

jsf file-upload primefaces
Rectangle 27 0

You should add the following filter to the web.xml :

<filter>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>PrimeFaces FileUpload Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

Also this question can be helpful ;)

Dear friend please eliminate one of the filter mapping in your web.xml, it's duplicated.

could you please provide me with the web.xml?

jsf - Primefaces file uploader doesn't call the handler method - Stack...

jsf jsf-2 primefaces
Rectangle 27 0

<p:button value="save" actionListener="#{indexBean.onSaveLunch}" />
<p:commandButton value="save" actionListener="#{indexBean.onSaveLunch}" />

The reason your method is not being called because it is not valid for actionListener.

public void onSaveLunch()
        {
            // do some action, will not be triggered
        }
public void onSaveLunch(ActionEvent event)
    {
        // do some action, will not be triggered
    }

Remember to import import javax.faces.event.ActionEvent; because there is another java swing action event which you don't want to use.

Thanks for the fast reply. I tried this before and it didn't work as well. I've retested it just a couple of seconds ago. That's a weird behaviour in my eyes. I know, that is my fault.

127.0.0.1 -  -  [18/May/2014:14:30:57 +0000] "POST /base/index.xhtml HTTP/1.1" 200 210 "http://localhost:8080/base/" [...]"

Thanks @Makkx for your update! But the Luiggi Mendoza's idea was (another working) solution.

java - Primefaces / JSF button's action handler will not trigger the r...

java jsf jsf-2 primefaces
Rectangle 27 0

You should use the right component and the right attribute. Change <p:button> by <p:commandButton> and use action instead of actionListener:

<p:commandButton value="save" action="#{indexBean.onSaveLunch}" />

If this doesn't work, then there's another problem within your code that you haven't shown. For that, update the question with your current code or check the reasons from here: commandButton/commandLink/ajax action/listener method not invoked or input value not updated

java - Primefaces / JSF button's action handler will not trigger the r...

java jsf jsf-2 primefaces
Rectangle 27 0

<filter>
  <filter-name>PrimeFaces FileUpload Filter</filter-name>
  <filter-class>org.primefaces.webapp.filter.FileUploadFilter</filter-class>
</filter>
<filter-mapping>
  <filter-name>PrimeFaces FileUpload Filter</filter-name>
  <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>

And you don't need those commons-io libs on WEB-INF\lib since you are using PF5 already. Remove them.

jsf - Primefaces 5 fileUpload handler not called - Stack Overflow

jsf file-upload primefaces
Rectangle 27 0

To show or close the dialog you only need to invoke it:

PF('widgetVarDialogName').hide();
PF('widgetVarDialogName').show();

You can open or close it in view actions, for example:

<p:commandButton
    value="Open dialog"
    type="button"
    onclick="PF('widgetVarDialogName').show()" />

<p:commandButton
    value="Do Action"
    action="#{myBean.myAction()}"
    oncomplete="PF('widgetVarDialogName').hide();" />

Also, you can invoke it from the bean if you want.

RequestContext.getCurrentInstance().execute("PF('widgetVarDialogName').show()");
RequestContext.getCurrentInstance().execute("PF('widgetVarDialogName').hide()");

(Remember, the dialog must be placed inside the form)

Thanks for the suggestion. I have a version working based on this. I still have a burning intellectual desire to know why the framework isn't working.

jsf 2 - Primefaces 5.1 Dialog Framework dialogReturn event handler not...

jsf-2 primefaces
Rectangle 27 0

To show or close the dialog you only need to invoke it:

PF('widgetVarDialogName').hide();
PF('widgetVarDialogName').show();

You can open or close it in view actions, for example:

<p:commandButton
    value="Open dialog"
    type="button"
    onclick="PF('widgetVarDialogName').show()" />

<p:commandButton
    value="Do Action"
    action="#{myBean.myAction()}"
    oncomplete="PF('widgetVarDialogName').hide();" />

Also, you can invoke it from the bean if you want.

RequestContext.getCurrentInstance().execute("PF('widgetVarDialogName').show()");
RequestContext.getCurrentInstance().execute("PF('widgetVarDialogName').hide()");

(Remember, the dialog must be placed inside the form)

Thanks for the suggestion. I have a version working based on this. I still have a burning intellectual desire to know why the framework isn't working.

jsf 2 - Primefaces 5.1 Dialog Framework dialogReturn event handler not...

jsf-2 primefaces
Rectangle 27 0

You should use the right component and the right attribute. Change <p:button> by <p:commandButton> and use action instead of actionListener:

<p:commandButton value="save" action="#{indexBean.onSaveLunch}" />

If this doesn't work, then there's another problem within your code that you haven't shown. For that, update the question with your current code or check the reasons from here: h:commandLink / h:commandButton is not being invoked

java - Primefaces / JSF button's action handler will not trigger the r...

java jsf jsf-2 primefaces
Rectangle 27 0

<p:button value="save" actionListener="#{indexBean.onSaveLunch}" />
<p:commandButton value="save" actionListener="#{indexBean.onSaveLunch}" />

The reason your method is not being called because it is not valid for actionListener.

public void onSaveLunch()
        {
            // do some action, will not be triggered
        }
public void onSaveLunch(ActionEvent event)
    {
        // do some action, will not be triggered
    }

Remember to import import javax.faces.event.ActionEvent; because there is another java swing action event which you don't want to use.

Thanks for the fast reply. I tried this before and it didn't work as well. I've retested it just a couple of seconds ago. That's a weird behaviour in my eyes. I know, that is my fault.

127.0.0.1 -  -  [18/May/2014:14:30:57 +0000] "POST /base/index.xhtml HTTP/1.1" 200 210 "http://localhost:8080/base/" [...]"

Thanks @Makkx for your update! But the Luiggi Mendoza's idea was (another working) solution.

java - Primefaces / JSF button's action handler will not trigger the r...

java jsf jsf-2 primefaces
Rectangle 27 0

I see you work a lot with the rendered="..." attribute. From what I experienced the <p:ajax event="dialogReturn" /> is not getting fired if itself or a parent element is not rendered.

public void accept()
<p:ajax event="dialogReturn" />
rendered="#{!grantManager.hasAccess(ss)}"
rendered="#{identity.loggedIn}"
false

A workaround just came to my mind. One can avoid the problem with the same workaround as if you want to trigger dialog framework from a <p:menuitem /> (Primefaces Dialog Framework dialogReturn event from menuitem).

Simply create a separate button somewhere outside of the possibly not rendered area and trigger it via javascript.

<ui:fragment 
    id="fragment" 
    rendered="#{...}">
    <h:commandButton
        id="pseudo_button"
        value="..." 
        onclick="document.getElementById('real_button').click()" />
</ui:fragment>

<h:commandButton 
    id="real_button"
    action="#{bean.realWorkHere()}"
    update="fragment"
    style="display:none;">
    <p:ajax 
        event="dialogReturn" 
        listener="#{...}" />
</h:commandButton>

jsf 2 - Primefaces 5.1 Dialog Framework dialogReturn event handler not...

jsf-2 primefaces
Rectangle 27 0

type="button"

From your commandButton. As long as its type is button it would only be clickable and won't send form data to the server.

jsf - How to connect command button to action handler in PrimeFaces mo...

jsf jsf-2 primefaces primefaces-mobile