How can I open a link from bean?I will open something like www.google.de.It should open the directory.
You can't open a link from a bean. A link requires enduser interaction.
Rather tell the browser directly to send a new GET request on the given URL. You can use ExternalContext#redirect()
for this.
public void action() throws IOException {
FacesContext.getCurrentInstance().getExternalContext().redirect("http://www.google.de");
}
This makes however no sense if that's the sole action of the bean. Rather use <h:outputLink>
or just <a>
instead of <h:commandLink action="#{bean.action}">
or something.
<h:outputLink value="http://www.google.de">link</h:outputLink>
<a href="http://www.google.de">link</a>