Rectangle 27 1

Don't see any "onclick" events inside the p:lightBox

So I guess you could use the help of jQuery... The following should work just fine (add to your js file or script tag)

jQuery(document).delegate(".imagebox", "click", function (event) {
    light.hide(); 
});
jQuery(document).delegate(".ui-lightbox-content-wrapper", "click", function (event) {
    light.hide(); 
});
....delegate("#idOfLightBox ",....
<p:lightBox styleClass="imagebox" widgetVar="light" onShow="jQuery(document).on('click', '.ui-lightbox-content-wrapper', function (event) {light.hide()});"> ...

You are welcome , I looked at the first primefaces showcase example that's why took that class as an anchor... (The Important part is the Idea behind...)

jsf 2 - Primefaces Lightbox: How to call hide()-method - Stack Overflo...

jsf-2 primefaces
Rectangle 27 19

Since PrimeFaces 3.3, you'd need to explicitly set the lazy attribute of the repeating component to true in order to enable the support for LazyDataModel.

<p:dataTable ... lazy="true">

Arrrrgggghh...So thats the reason, I have built a small app that uses lazydatamodel using Primefaces 3.1. I was just following along when I encounter this in the latest 3.4 build.. Thanks as always BalusC..

You're welcome. Been there, done that ;)

I have version 3.5 and i already set lazy="true" in my dataTable. But still load() method in lazyDataModel is not getting called. Do you have any idea ?

Even with Datatable attribute lazy="true", some other Datatable attributes can inhibit lazy loading, causing UnsupportedOperationException with message "Lazy is loading not implemented", (generated by the load() stub in LazyDataModel). Try removing attributes such as sortMode and sortBy, and set paginator="true" rather than having it set by a bean property.

jsf 2 - PrimeFaces lazydatamodel load method not called - Stack Overfl...

jsf-2 primefaces
Rectangle 27 9

Today I hit this exact same problem with PrimeFaces 5.1. In my case I had no nested forms and I was already setting the process attribute on the p:commandButton with the form elements I wanted to be processed. However this didn't work yet.

The "solution" was to add @this to the list of components to process, like this:

<p:commandButton process="myFormField1 myFormField2 @this">

Without @this (which is not usually needed, since the button itself shouldn't need to be processed/validated) I found no way to make any of these to work inside a composite:

<p:commandButton action="#{bean.myAction}"...>
<p:ajax event="click" action="#{bean.myAction}"...>
<p:remoteCommand name="myAction" action="#{bean.myAction}">

By debugging the application, I saw that the validation and update model phases were correctly executed, but then in the invoke application phase no queued event was present and hence no action was performed. Actually, I could specify anything I liked inside the action and actionListener attribute values of <p:commandButton> without having either PrimeFaces or JSF complain in any way.

These, instead, do work as they should, but you don't have partial processing in place, so they may not be a viable solution:

<p:commandButton action="#{bean.myAction}" ajax="false"...>
<p:commandButton type="button"...>
<f:ajax event="click" action="#{bean.myAction}"...>

It must be a PrimeFaces bug.

button is not fired, if it is not processed. it makes sense.

It does not, since the "process" attribute indicates which other fields should be processed/submitted. Setting "@this" in the process attribute is not required for buttons outside a composite. And, if it were, it would be at least "redundant".

jsf 2 - PrimeFaces CommandButton Action not called inside Composite - ...

jsf-2 primefaces composite-component
Rectangle 27 34

You seem to be expecting that the valueChangeListener method in the server side is called immediately when a change event occurs on the client side. This is not correct. It will only be invoked when the form is submitted to the server and the new value does not equals() the old value.

Add onchange="submit()" so that JavaScript will submit the form whenever you change the value:

This is however very JSF-1.x-ish and poor for user experience. It will also submit (and convert/validate!) all other input fields which may not be what you want.

Make use of an ajax listener instead, for sure if you are not interested in the actual value change (i.e. the old value is not interesting for you), but you're actually interested in the change event itself. You can do this using <f:ajax> or in PrimeFaces components using <p:ajax>:

<p:selectOneMenu style="width: 220px;" 
   value="#{customerProfileSessionBean.selectedAccount}">
    <p:ajax listener="#{customerProfileSessionBean.accountValueChange}" />
    <f:selectItems value="#{sessionBean1.custAccountList}"/>
</p:selectOneMenu>
ValueChangeEvent
AjaxBehaviorEvent

Thanks. I was exxpecting the PrimeFaces component to do the submit() as part of the component's ajax behavior.

Your selcond solution worked very well for be, but only if i changed the <f:ajax to <p:ajax... also I think it's good to point out what the signature or the callback method should be. so in this case it would be public void accountValueChange(ValueChangeEvent event){...}

BalusC is spot on.Even more fun, although I am not sure if it is legit., is just to insert <p:ajax></p:ajax> inside the menu and leave the valueChangeListener attribute of the menu intact. For some reason the ajax will fire the valueChangeEvent when the item changes. I have tested this exhaustively to make an immediate change to a locale and it works a dream.

@Tim: The value change listener is fired when the submitted value differs from the initial value. All what ajax does is submitting the form. That's not so weird as you seem to imply. However, if you're not intersted in the change itself, but only in the newly submitted value, then a value change listener is the wrong tool for the job. See also stackoverflow.com/questions/11879138/

jsf 2 - How do I get PrimeFaces to call valueChangeL...

jsf-2 primefaces
Rectangle 27 5

When you used the composite component, was it already placed in a h:form tag? When you have nested forms, command button action isn't triggered.

Another issue can be the ajax parts that you are trying. Primefaces button has the update attribute, but the standard JSF one does not have that. It will do always a complete refresh of the page (except when nested in or f:ajax tag is used inside it)

jsf 2 - PrimeFaces CommandButton Action not called inside Composite - ...

jsf-2 primefaces composite-component
Rectangle 27 8

That's because HTML and HTTP does not understand Java objects. All Java objects are converted to String when HTML is to be produced by JSF. All HTTP request parameters which are String are supposed to be converted back to Java object when the submitted form data is to be processed by JSF.

As to your concrete problem, if you have added a <h:message>, <h:messages> or the PrimeFaces equivalent to the form (and also updated it on ajax submits), then you should have noticed a conversion error for "null converter". Also, if you have paid attention to the server log, you should also have seen a warning about an unhandled message.

You need to create a custom Converter which converts between MyObj and its unique String representation. For example:

@FacesConverter(forClass=MyObj.class)
public class MyObjConverter implements Converter {

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object valueToRender) {
        // Convert MyObj to its unique String representation.
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
        // Convert String to MyObj.
    }

}

Usually those objects are already stored in some database or mapping by their ID. You then use exactly that ID as unique String representation.

jsf 2 - Primefaces selectOneMenu listener not called with Objects othe...

jsf-2 primefaces tomcat7
Rectangle 27 8

That's because HTML and HTTP does not understand Java objects. All Java objects are converted to String when HTML is to be produced by JSF. All HTTP request parameters which are String are supposed to be converted back to Java object when the submitted form data is to be processed by JSF.

As to your concrete problem, if you have added a <h:message>, <h:messages> or the PrimeFaces equivalent to the form (and also updated it on ajax submits), then you should have noticed a conversion error for "null converter". Also, if you have paid attention to the server log, you should also have seen a warning about an unhandled message.

You need to create a custom Converter which converts between MyObj and its unique String representation. For example:

@FacesConverter(forClass=MyObj.class)
public class MyObjConverter implements Converter {

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object valueToRender) {
        // Convert MyObj to its unique String representation.
    }

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String submittedValue) {
        // Convert String to MyObj.
    }

}

Usually those objects are already stored in some database or mapping by their ID. You then use exactly that ID as unique String representation.

jsf 2 - Primefaces selectOneMenu listener not called with Objects othe...

jsf-2 primefaces tomcat7
Rectangle 27 4

You can't and shouldn't nest forms.

ClientMaster.xhtml
<ui:include id="ce" src="ClientEditDatatable.xhtml"/>
        </h:form>
</h:form>              
        <ui:include id="ce" src="ClientEditDatatable.xhtml"/>

jsf 2 - primefaces commandbutton actionlistener not called - Stack Ove...

jsf-2 primefaces actionlistener
Rectangle 27 1

Your listener is not being called, as you probably have some validation errors. In the JSF Life-cycle Phase 3 is the "Process Validations" Phase, if this phase fails JSF will immediately jump to phase 6, which is "Render Response" Phase. So phase 5 "Invoke application" where the listener gets called, will be skipped.

Make sure that neither deviceBean nor inputControlGroupId is null and applies the given constraint.

#{deviceBean.inputControlGroupId}

Thanks Sonic, that seems to be on the right track. However neither deviceBean nor inputControlGroupId are null but the param doesn't always exist. The cgId viewparam is an optional input param so when it is not defined I am getting the issue but when it is defined I don't. Also why don't I get some validation exception? I can remove the validation tag as it is not too important in my case but would be nice to fully understand what is going on.

As cgId is an optional param you should render the validation tag only if this param has been set. You can do this by adding a corresponding <c:if/> test. As the variable has not been set, you will get a RuntimeException Nullpointer Exception, not a checked Validation Exception, when JSF tries to access this parameter in it`s validation phase. This is why your program crashes.

jsf 2 - PrimeFaces Poll listener not called - Stack Overflow

jsf-2 primefaces
Rectangle 27 5

Your concrete problem is caused because you've turned off ajax by ajax="false". This will create a synchronous form submit which makes it impossible to fire an ajax request along. If you remove ajax="false", then it will likely work, but you've still a race condition if the one method depends on the result of the other. It's not defined which one would be executed first.

Better just use a single command component. You can use action and actionListener together. The action is intented for business actions. The actionListener is intented for preparing of business actions. If you need more action listeners, just nest a <f:actionListener> or perhaps a <f:setPropertyActionListener>.

<p:commandButton value="Submit"
    actionListener="#{userBean.correlation}"
    action="#{userBean.execute}"
    update="correlationDialog" />

Thanks Balus..I have tried by removing off ajax but it did not worked.

I also tried with single command component that you have suggested,but in this approach it is executing correlation method first followed by execute method..But I want to execute both methods at the same time not one by one...So is there any other way to execute both methods at the same time?

Why exactly would you want to do that? Do you realize that you need 2 threads for that? The above answer just executes the both methods in 1 enduser interaction.

Yes exactly..I need to threads that will run in parallel..But before implementing threading I am looking for some other option..How to run two bean methods simultaneously in JSF without implementing Threading.

Actually the problem is If I marge these two methods and create a single bean method that executes after click on submit button..it takes too much time to execute and load the xhtml page.To minimize this loading and execution time I converted this single method in two different methods.

jsf 2 - Call multiple bean method in primefaces simultaneously - Stack...

jsf-2 primefaces
Rectangle 27 1

I had also problems with non-triggering commandButtons. In my case ajax and non-ajax reqeuests didn't work. 1. as described above - be sure to delete all form's in form's. easy done with composite usage. 2. if you have several buttons, try to use the flag "process". Helped in my case.

<p:commandButton id="submitButton" value="Submit" type="submit" 
    actionListener="#{bean.save}"
    update="message"
    process="txtComment, @this"
    icon="ui-icon-disk"/>

process="txtComment, @this" executes the setter method of inputText with id txtComment and the commandButton method.

jsf 2 - PrimeFaces CommandButton Action not called inside Composite - ...

jsf-2 primefaces composite-component
Rectangle 27 2

<p:selectOneMenu style="width: 220px;" value="#  
      {customerProfileSessionBean.selectedAccount}"
             valueChangeListener="#{customerProfileSessionBean.accountValueChange}" >
      <f:selectItems value="#{sessionBean1.custAccountList}"/>
       <f:ajax render="@form"/>
       </p:selectOneMenu>

Or you can provide panel id or datatable id ,if you dont want torender the whole form, like:

<f:ajax render=":formid:panelGroupId"/>

jsf 2 - How do I get PrimeFaces to call valueChangeL...

jsf-2 primefaces
Rectangle 27 16

RemoteCommand is a nice way to achieve that because it provides you a JavaScript function that does the stuff (calling backing bean, refreshing, submitting a form etc., everything that command link can do).

<p:remoteCommand name="increment" actionListener="#{counter.increment}"
out="count" />

<script type="text/javascript">
function customFunction() {
    //your custom code
    increment(); //makes a remote call
}
</script>

ajax - Using Primefaces JavaScript to call a JSF method on a bean on t...

javascript ajax jsf primefaces
Rectangle 27 1

<f:ajax render="mdateOfValuation" event="blur"/>

with

<p:ajax update="mdateOfValuation" event="blur"/>

And in general don't use f:ajax with primefaces components

jsf 2 - ajax call breaks primefaces calendar component - Stack Overflo...

jsf-2 primefaces
Rectangle 27 1

<h:outputText value="Name " />
<p:inputText id="name" value="#{newOrderBean.name}">
    <f:ajax event="keyup" render=":form2:maintab:name_id" />
</p:inputText>

jsf 2 - Fail to update h:outputText tag with (Primefaces) p:ajax call ...

ajax jsf-2 primefaces
Rectangle 27 4

Not when using native JSF or PrimeFaces. Your best bet would be to hook on session expiration instead.

If you happen to use the JSF utility library OmniFaces, then you can use its @ViewScoped. This will call the @PreDestroy when leaving the page referencing the view scoped bean.

import javax.inject.Named;
import org.omnifaces.cdi.ViewScoped;

@Named
@ViewScoped
public class Bean implements Serializable {

    @PreDestroy
    public void destroy() {
        // Your code here.
    }
}

Under the covers, it works by triggering a navigator.sendBeacon() during the window beforeunload event with a fallback to synchronous XHR (which is deprecated in modern browsers supporting navigator.sendBeacon()).

Is there a way to call a method upon leaving a page with JSF or PrimeF...

jsf primefaces managed-bean window.onunload
Rectangle 27 4

What I've typically done is put a hidden p:commandLink on the page, then have Javascript call the click() event on it.

<p:commandLink id="hiddenLink" 
   actionListener="#{bean.methodToInvoke}" style="display:none"/>
$('#hiddenLink').click();

Depends on whether those parameters are fixed or need to be adjusted client-side via javascript as well. If they don't change, you can use f:attribute. If they might change client-side, I've used h:inputHidden elsewhere on the form to push those along to the managed bean.

In my case, the element from <p:commandLink id="hiddenLink"> is NOT given the id "hiddenLink". Instead, it is given the id "j_idt5:hiddenLink". Therefore, I cannot find it.

ajax - Using Primefaces JavaScript to call a JSF method on a bean on t...

javascript ajax jsf primefaces
Rectangle 27 4

To rerun a script, simply re-render the tag that calls it. Assuming the form is re-rendered whenever it is "updated", this will do:

<script>

function init () { 
  $("#myspan").doSomething;
}
</script>

<h:form rendered="some condition">
  <script type="text/javascript">init()</script>
  <span id="myspan" />

</h:form>

jsf - Automatically call javascript on update of some component in Pri...

javascript jsf jsf-2 primefaces
Rectangle 27 1

You should not call any Expression Language directly into a non-JSF component. What you're looking for is for an <h:commandLink> instead:

<h:form>
    <h:commandLink action="#{Login.logout()}" styleClass="foo">
        <span style="...">logout</span>
    </h:commandLink>
</h:form>

Where foo is a CSS class where you clear the default formatting for an <a>. Then, you can use the common HTML <span> component to apply the desired CSS to your logout text.

JSF/Primefaces span onClick automatically calls Backing Bean - Stack O...

jsf primefaces
Rectangle 27 2

If you use omnifaces @ViewScoped annotation in the backing bean the bean object is destroyed when you leave the view; so you can call a function when this happens using the @PreDestroy annotation in it.

Note: You must use omnifaces @ViewScoped annotation; with standard JSF @ViewScoped annotation the object isn't destroyed just by leaving the view, so pay attention to the import!

Is there a way to call a method upon leaving a page with JSF or PrimeF...

jsf primefaces managed-bean window.onunload