Sunday, November 27, 2011

Display partial Strings using OutputText and JSTL

Here is how you can display a substring in JSF using h:outputText and JSTL.

Add the JSTL functions namespace: xmlns:fn="http://java.sun.com/jsp/jstl/functions" to your JSF page.

Use JSTL in the EL Language: #{fn:substring(item.NameOfItem,0,10)} .

That is it!

Thanks.

Tuesday, February 8, 2011

Annotations For Managed Beans

Thanks to annotations you don't have to mess with xml configuration files as much.
Here is an example of how to use ManagedBean annotations for your managed beans.

Faces Config Entries:

</managed-bean\>
</managed-bean-name\>myBean\</managed-bean-name\>
</managed-bean-class\>org.mybeans.MyBean</managed-bean-class\>
</managed-bean-scope\>session</managed-bean-scope\>
</managed-bean\>

Annotation Alternative:

@ManagedBean(name="myBean")
@SessionScoped
public class MyBean {

}

That's all!