preload
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:
Mrz 02

Due to the fact I got in touch with maven2 and I think that maven2 is very helpful will give a short introduction. Bigger projects normally have a more complex configuration but I will start from the scratch.

Maven will create a kind of project sceleton with the following command

1
mvn archetype:create -DgroupId=info.sobek.testapp -DartifactId=testapp

If you work with e.g. eclipse, you can create the project files for eclipse:

1
mvn eclipse:eclipse

Now you can import it into eclipse with “import into existing workspace” option of eclipse.

Maven will normally copy the created so called “artifacts” into your local maven repository. Normally located under your home dir and then .m2

When you program depends on several jars and these dependencies are defined in the pom.xml, then maven will copy the jars in their specific version into the local maven repository. This is very helpful because you can simply build your project with another newer or older version of your dependent jar-file.

How to create multi-module projects will be explained in another episode.

Tagged with: