h:commandButton to cancel sending a form (without validation)

February 8th, 2010

Sometimes the problem with validators is that you can’t send a cancel button from within a form, because the validator stops processing it. In this case it is usefull to set the button on immediate=”true”, but then the problem might be that the view ist not correctly cleared. To force clearing the view, it is important to navigate with an outcome other than null (”").

    <h:commandButton immediate="true"
        actionListener="#{bean.discardEditing}"
        value="#{msg.action_cancel}" />

In the example “bean.discardEditing” does some cleanup and returns a navigation outcome to navigate to the same screen again, e.g. “revertToEdit”.

See also:

jsf: general error message (e.g. on top of a form)

February 8th, 2010

To put a general error message on screen, that is shown only if errors occurred (but is not h:messages) use:

facesContext.maximumSeverity

An example:

    <h:panelGroup rendered="#{! empty facesContext.maximumSeverity}">
        <h:outputText styleClass="error" value="Some errors occurred." />
        ...
    </h:panelGroup>

a4j:commandLink and a4j:support problem

January 27th, 2010

Avoid to mix those two up. Do NOT nest them to trigger rerendering, like this:

    <a4j:commandLink ajaxSingle="true" actionListener="#{...}">
        <a4j:support event="onclick" reRender="..." />
    </a4j:commandLink>

It will lead to funky behaviour, sometimes sending the link, sometimes not. If you use a4j:commandLink you do not need a4j:support. Do trigger rerendering from within the commandLink.

    <a4j:commandLink ajaxSingle="true" actionListener="#{...}" reRender="..." />

Eclipse Memory

January 20th, 2010

http://www.eclipsezone.com/eclipse/forums/t61618.html

Is your project a death march?

January 7th, 2010

If your project appears to be a death march, you might like this:

http://www.youtube.com/watch?v=KcyzF06ridc

(german language)

md5 on a string

December 18th, 2009

To get the md5 hash of a string from the command line, do e.g. this:

echo -n hallo | md5sum

It is important to do “echo -n” to prevent echo from outputting the trailing new line. Otherwise the newline will be included in the hash.

Using Eclispe behind a proxy

November 19th, 2009

this link might be helpful: wiki.eclispe.org

by the way: you don’t need to store your username and password as plain text info in the ini file! For security reasons I think you should leave it out, because Eclipse will ask you for it later.

tail -f with highlighting

October 5th, 2009

Use

tail -f /path/to/my.log | perl -p -e 's/(KEYWORD_1|KEYWORD_2)/\033[7;1m$1\033[0m/g;'

to highlight all occurences of KEYWORD_1 and KEYWORD_2 in tail -f.

h:outputText in facelets

August 19th, 2009

With facelets you can omit the h:outputText tags. Instead of

    <h:outputText value="#{msg.editEmployee_name}" />

you can just write

    value="#{msg.editEmployee_name}"

Eclipse code formatting and cvs comments

July 29th, 2009

I sometimes hat the problem that the auto formatting of eclipse destroyed my cvs comments.

unordered cvs comments

But the solution is very easy. You just have to use

/*-

instead of

/*

to start the comment . That’s it and eclipse will not format your cvs comments any more.

ordered cvs comments