preload
Okt 26

I recently read in a chapter of Rod Johnsons Book “expert one-to-one, J2EE Design and Development” an interesting sentence:

A professional programmer or architect cares more about learning and discovering the best solution than the buzz of finding their own solution to a particular problem.

This is so true. Don’t waste (project) time with finding a very own solution and reinventing the wheel. Find solutions that fit your needs, learn how they solved the problem. Of course they must fit to your problem with a coerage of lets say >90%. But these solutions are tested.

Tagged with:
Okt 14

Situation:
You created a composite component in JSF 2.0. This component now should have some attributes which contains direct links. This links should now be declared when you use the component.
Example:

1
2
3
    <composite:attribute type="java.lang.String" required="false"
        name="logoutURL" default="/faces/logout.jsf"
        shortDescription="The logout URL." />

Later in the implementation you use it like the following example:

1
2
		<h:commandLink action="#{cc.attrs.helpURL}"
			value="#{textbundle['status.linktext.logout']}" />

Problem
You now get a class cast exception. JSF excepts a String result of a method which you can use in the action attribute of commandLink. Directly putting a String in this result is ok.

Solution
Use toString (although you declared the attribute as type of String)

1
2
		<h:commandLink action="#{cc.attrs.helpURL.toString}"
			value="#{textbundle['status.linktext.logout']}" />
Tagged with: