jQuery in Action, 3rd edition
The moose likes JSF and the fly likes Open mailtool from a commandButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Open mailtool from a commandButton" Watch "Open mailtool from a commandButton" New topic

Open mailtool from a commandButton

Tom Zeiti

Joined: Feb 16, 2012
Posts: 2

I am trying to open an eMail tool (same as typing the URL "mailto:john.doe@web.com" into my web browser) from a commandButton.
I tried things like

<h:commandButton value="send mail" action="#{myBean.email}"/>

and in the bean:

public String email() {
return "mailto:john.doe@web.com";

But this gives an error message since, of course, the JSF framework tries to convert the return string into some other address, e.g. adding .xhtml and so on.
How can I avoid that the address is processed in such a way?

Thanks for your help!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17148

Welcome to the JavaRanch, Tom!

Use the commandLink tag, instead. That will give you what you want.

An IDE is no substitute for an Intelligent Developer.
Tom Zeiti

Joined: Feb 16, 2012
Posts: 2
Yes, using the command link was also what I ended up doing. So I try to figure out how to make the command link look like a button so the user won't notice...
Thanks for your help!
Lars Weje Hangstrup

Joined: Oct 30, 2012
Posts: 1
Found this:

I agree. Here's the link: http://aspose.com/file-tools
subject: Open mailtool from a commandButton
It's not a secret anymore!