How do I process GET query string URL parameters in backing bean on page load?

Yes, you can use the <f:viewParam> to set a request parameter as a managed bean property. <f:metadata> <f:viewParam name=”companyId” value=”#{bean.companyId}” /> </f:metadata> You can if necessary invoke a bean action using <f:viewAction> (JSF 2.2+ only) or <f:event type=”preRenderView”>. <f:metadata> <f:viewParam name=”companyId” value=”#{bean.companyId}” /> <f:viewAction action=”#{bean.onload}” /> </f:metadata> When using <f:viewAction> you can even return a … Read more

Execution order of events when pressing PrimeFaces p:commandButton

It failed because you used ajax=”false”. This fires a full synchronous request which in turn causes a full page reload, causing the oncomplete to be never fired (note that all other ajax-related attributes like process, onstart, onsuccess, onerror and update are also never fired). That it worked when you removed actionListener is also impossible. It … Read more

JSF doesn’t support cross-field validation, is there a workaround?

The easiest custom approach I’ve seen and used as far is to create a <h:inputHidden> field with a <f:validator> wherein you reference all involved components as <f:attribute>. If you declare it before the to-be-validated components, then you can obtain the submitted values inside the validator by UIInput#getSubmittedValue(). E.g. <h:form> <h:inputHidden id=”foo” value=”true”> <f:validator validatorId=”fooValidator” /> … Read more

Concatenating strings within EL expression defined in an attribute of a facelets tag

It is possible to concatenate Strings in EL using the java.lang.String.concat(String) method. Thus your code could look like: <h:outputText value=”#{cc.attrs.appreciatedByCurrentUser ? (”.concat(cc.attrs.count).concat(‘&lt;br/&gt;’).concat(cc.attrs.count-1)) : (”.concat((cc.attrs.count+1)).concat(‘&lt;br/&gt;’).concat(cc.attrs.count))}” escape=”false” /> In this particular case however I would go with one of the options that Mr BalusC had suggested because the code above doesn’t look quite elegant. In some cases … Read more

The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within

This is just a Warning not an Error. Warnings are usually there to inform the developer about unforeseen situations/conditions which might not immediately cause technical errors/problems. Anything may just work flawlessly, but the behaviour/results may probably not be as the developer intented. A newbie developer may for example accidently have used <form> instead of <h:form>. … Read more

PrimeFaces commandButton doesn’t navigate or update

<p:commandButton> needs one of the following to work correctly: the update attribute to list id’s of components to re-render (for AJAX requests) the attribute ajax=”false” to make a normal, non-ajax submit. If you have neither, the button does per default an AJAX request with no UI feedback. Additionally, I’ve had problems with neither option working … Read more

Facelets repeat Tag Index

Specify a value for the “varStatus” attribute: <ui:repeat id=”…” var=”…” value=”…” varStatus=”myVarStatus”> You can then access the loop index via EL: #{myVarStatus.index} Additionally, the following properties are available to the varStatus: begin of type Integer end of type Integer index of type int step of type Integer even of type boolean odd of type boolean … Read more

Difference between h:link and h:outputLink

<h:link> uses its value attribute as the link text and its outcome attribute to generate the linked-to URL via JSF navigation rules. This makes it useful for application-internal links. Also, this component was introduced only on JSF 2.0 <h:outputLink> uses the value attribute directly as linked-to URL and the content of the tag as link … Read more

How to set width of a p:column in a p:dataTable in PrimeFaces 3.0?

In PrimeFaces 3.0, that style get applied on the generated inner <div> of the table cell, not on the <td> as you (and I) would expect. The following example should work out for you: <p:dataTable styleClass=”myTable”> with .myTable td:nth-child(1) { width: 20px; } In PrimeFaces 3.5 and above, it should work exactly the way you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)