4

Simple question:

Is there any way of rendering a html <button>-element using JSF or any other framework (RichFaces, Tomahawk etc.)? Or would I have resort to writing a custom component for this?

Per H
  • 1,542
  • 10
  • 19
  • +1 **Great question!** I was searching for that, but it seems anyone minds about it. – Alba Mendez Feb 15 '12 at 16:39
  • A clarification: you need to write a custom **renderer**. The `h:commandButton` and the `h:commandLink` are, in fact, **the same component** (`UICommand`), but every tag uses a different renderer. So just **1)** write and register your own ` – Alba Mendez Feb 15 '12 at 16:45

1 Answers1

0

No, there isn't. Since a <button> is usually only used in GET requests, you can also just put it plain vanilla in the JSF template. You don't need to bind any action to a JSF managed bean anyway.

In JSF 2.0, there's by the way the <h:button> which renders a GET button and offers the option to include view parameters and/or to perform implicit navigation. Both features aren't available in JSF 1.2, so there's not really a point of having similar component in JSF 1.2 anyway.

On the other hand, if you actually intend to use a <button> to invoke a POST managed bean action method, then you should really be using a <h:commandButton> instead. If you're having a specific problem with it for which you thought that using <button> was the solution, then you'd need to reframe your question to elaborate in more detail about that specific problem so that we can answer how to achieve the same with <h:commandButton>.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 2
    AFAIK, the only difference between an and a – Per H Oct 05 '11 at 07:28
  • And since I want the button to trigger a method in my bean, using plain vanilla html isn't really an option (unless I use it to trigger a , but that seems like a really ugly solution. – Per H Oct 05 '11 at 07:31
  • If all you want is a background image for the button, just use CSS `background-image`. – BalusC Oct 05 '11 at 12:19
  • Yeah, I know, but that doesn't quite cover my needs. Thanks anyway though. – Per H Oct 05 '11 at 13:24