tags:

views:

148

answers:

2

Theres a web page I'm making which content is very dynamic and so I'm building it from inside the backing bean.

I would like to add a Java applet to the web page but I could not find the JSF component type to correspond to the <applet> tag.

So My questions are -

  1. What is the JSF component type for an applet?
  2. How did you find it? (For similar future searches)

Thanks!

P.S - Just to be clear. An example: <h:PanelGroup> would be HtmlPanelGroup as a java object.

+2  A: 

Couple of things to start with; The <applet> tag is deprecated in favour of <object>, and JSF doesn't really provide a tag to render <object>. That said you can use f:verbatim if you're at tag level, which I believe corresponds to UIOutput.

JSF doesn't guarantee a Java object representation of all client side tags (nor should it). What you're trying to do is move all markup knowledge into the backing bean, and truthfully, that way lies madness.

I'd suggest that you take a look at Facelets, a compositing technology that sites on top of JSF. It lends itself very well to flexible page production and keeps markup and page composition out of your backing beans and in X/HTML files. Facelet's has also been embraced for JSF 2.0.

dannywartnaby
Thanks. I'll read into that.Honestly, I couldn't find a way to make web pages really dynamic from the JSP markup language. Like adding and removing components and switching panels dynamically. I know that therotically these things are possible but to achieve them I will have to work really hard whereas in the backing bean I can create abstractions and avoid code duplication. I understand why it sounds like madness but in practice, I don't think it is.If you have a good read on why it's bad to do this I will be glad to read.
Ben
Decent tutorial: http://www.ibm.com/developerworks/java/library/j-facelets/ will give you a good idea of what Facelets is and the problems it solves. JSF on it's own, out of the box, is a bizzare beast, Facelets on the other hand provides lots of support for conditional rendering of page compositions. I don't have any specific link for you on why generating the UI in code is a bad idea, but if you google around 'seperation of concerns' you'll get the gist. Ultimately your approach tightly couples your UI with the rest of you app; a new button needs code changes and a recompile, for example.
dannywartnaby
It's probably also worth pointing out one of the key benefits of Faces; you can design your pages in any valid HTML editor or text editor, and there are also many rich libraries of components for you to take of advantage of. Each element has a rendered attribute, which you can pass a boolean to in order to conditionally render it, for example - you can start to see from this how dynamic, flexible pages can be built. And also, adopting Facelets now puts you in a good position for a JSF 2.0 upgrade later.
dannywartnaby
+2  A: 

There appears to be a ready-to-use component for that.

Alternatively, you can write your custom component that will output the <object> tag. It's relatively easy.

Bozho