5/19/2013

Primefaces 3.5.4 released

For those of you who use primefaces : 3.5.4 is out.
Check out the changelog here : http://blog.primefaces.org/?p=2646

If you like this post it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

5/06/2013

Validating Checkboxes in Primefaces

Validation is a good thing if you are going to make the data your get more robust. Almost all gui elements can be validated using the "required" attribute but not checkboxes. The problem is that JSF "translates" a non-checked checkbox to Boolean.FALSE which still fullfils the "required" requirements. The solution is rather easy: 

Write a validator that you´ll bind just to this one component and check for the Boolean.FALSE value yourself:


public class CheckboxValidator implements Validator {

 public void validate(FacesContext context, UIComponent component, Object value)

 throws ValidatorException {

   if (value.equals(Boolean.FALSE)) {
     throw new ValidatorException( new FacesMessage(FacesMessage.SEVERITY_ERROR, "message" "message"));

   }

 }

If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.

Liferay, MP3 and Internet Explorer

When you are using HTML5 libraries to play video and audio in Internet Explorer and you are using liferay in a tomcat to provide your mp3 files you might have noticed that, under certain circumstances, Internet Explorer refuses to play your files.
The cause of this issue might be that IE9 (and earlier) have a problem with the audio/x-mpeg content type. Tomcat uses audio/x-mpeg as standard content type for all MP3 files. To change it you need to open the web.xml file you will find under $tomcat-dir/conf .
Replace

<mime-mapping>
        <extension>mp3</extension>
        <mime-type>audio/x-mpeg</mime-type>
</mime-mapping>
with
<mime-mapping>
        <extension>mp3</extension>
        <mime-type>audio/mpeg</mime-type>
</mime-mapping>

and it should work.


If you like this tutorial it would be very nice, if you could click on some of the google ads you see on the right side. It helps me run this block and motivates me ;)

If you have any questions, feel free to leave a comment.