Wednesday, 11 November 2009

javax.naming.NameNotFoundException: name_of_your_resource

Don't forget to include jdbc for your jdbc resources.

Monday, 9 November 2009

Dependency injection in javax.faces.validator.Validator

Using no additional frameworks (Seam for example) it's impossible to @EJB in Validator. Let me know if I am wrong.

My workaround is based on a question, why bother? Just provide a validation method on a managed bean.

jQuery and JSF

JSF appends parent ID to child ID.

<h:form id="form">
  <h:inputtext id="input" />
</h:form>

input is then rendered with id form:input.

That's actually nice, but jQuery doesn't understand $("#form:input") - doesn't like the colon and throws an exception.

Workaround looks like this - $("[id=form:input]").

Monday, 21 September 2009

Generics and getResultList()

So, this is a common problem with a dirty workaround.

If you try

public List<YourClass> getAllResults()
{
  return entityManager.createNamedQuery("YourClass.findAll").getResultList();
}

You get this:

found   : java.util.List
required: java.util.List<YourClass>
    return (List<YourClass>) entityManager.createNamedQuery("YourClass.findAll").getResultList();

or if you haven't compiled with -Xlint:unchecked, this Note: YourClass.java uses unchecked or unsafe operations.

The issue is described here

Saturday, 19 September 2009

Detecting Errors From Request Processing in JSF Pages

Recently I came across a little problem — display a portion of JSF only if the request was successful, i.e. no validation errors and if the request has actually been sent to the server (no request, no errors). Here is what I did:
<h:outputText
  rendered="#{empty facesContext.maximumSeverity && !empty Enquirer.name}"
  value="Thank you. You message has been sent."/>
The source that pointed me in the right direction.

JSF + Managed Beans + Managed Properties

I have stumbled upon this article (by Chris Schalk)while trying to remember what <managed-property> meant  in faces-config.xml.

Very interesting and useful when you're developing JSF backed by EJB3.0.