File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes JSF rendering the whole page : Even the basic html tags Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "JSF rendering the whole page : Even the basic html tags" Watch "JSF rendering the whole page : Even the basic html tags" New topic
Author

JSF rendering the whole page : Even the basic html tags

Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Is there a plan to provide JSF tags for even basic html tags?
[something like <h:td> or <h:tr> ]

As in certain case, I have to control the display of a particular section based upon certain condition (e.g. Accordian functionality).
Now I can stop the display of JSF Components using "rendered" attribute, but can't stop the rendering of html tags such as TD,TR etc.
Ultimately the only option left is to control the display using DHTML.

I also noticed the plug-in provided by htmlLib, but didn't used as was a bit apprehensive about the future of the same (support, enhancements etc.)

Thanks,
[ December 16, 2004: Message edited by: K Varun ]

- Varun
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

You should really use panelGrid for rendering tables in JSF and you can group components with panelGroup.


GenRocket - A Test Data Generation Platform
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Originally posted by Gregg Bolinger:
You should really use panelGrid for rendering tables in JSF and you can group components with panelGroup.


Never looked at this element. Seems cool
Thanks,


Now, well, I ran an simple example :



Now my concern is, if i want to render the element
<h utputText value="3" />
as <td colspan="2">3</td>
will I be able to do that? i.e. Using colspan attribute "only" in a single element?
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

You can't really supply a colspan attribute to a single row, but what you can do is:



Basically, you are supplying empty TD elements which may or may no look right depending on your table styles (cellpadding, cellspacing, etc) but that is a decent work around.
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Atleast this attribute could have been provided in panelGroup, even that would have solved this problem.

anyways, Thanks for your help
[ December 16, 2004: Message edited by: K Varun ]
Cay Horstmann
author
Ranch Hand

Joined: Nov 14, 2004
Posts: 114
    
  10
I think it is worth pointing out that the HTML elements aren't outlawed in JSF pages. If you prefer layout with table/tr/td, you can still do that.

I have often wondered if JSF programmers have gone overboard in eliminating HTML tags. It seems a lot simpler to have a graphic designer produce beautiful HTML and then insert the JSF tags. That's just fine as long as you don't need alternate markup--and let's face it, for most apps, HTML is all you need.

There are a few unfortunate situations where HTML tags that are nested inside JSF tags will render out of order. (This is a consequence of JSF being built on top of JSP.) But in practice, these situations can always be avoided.

Cheers,

Cay


Author of Java 8 for the Really Impatient
Varun Khanna
Ranch Hand

Joined: May 30, 2002
Posts: 1400
Thanks Cay,

Also do you have an idea why layout stuff has been omitted in JSF (I hope I didn't missed if it's already there).
Being a front end technology, why didn't JSF provided few basic layouts like GridBag, FlowLayout etc.
Though I have seen few IDEs providing basic layout functionalities, but again the "properiety fear" can easily stop any one from using these properiety feature of IDEs.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Originally posted by K Varun:
Thanks Cay,

Also do you have an idea why layout stuff has been omitted in JSF (I hope I didn't missed if it's already there).
Being a front end technology, why didn't JSF provided few basic layouts like GridBag, FlowLayout etc.
Though I have seen few IDEs providing basic layout functionalities, but again the "properiety fear" can easily stop any one from using these properiety feature of IDEs.


MyFaces provides a page layout. I would guess that JSF leaves this detail up to the implementation.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15286
    
    6

Originally posted by Cay Horstmann:
I think it is worth pointing out that the HTML elements aren't outlawed in JSF pages. If you prefer layout with table/tr/td, you can still do that.

I have often wondered if JSF programmers have gone overboard in eliminating HTML tags. It seems a lot simpler to have a graphic designer produce beautiful HTML and then insert the JSF tags. That's just fine as long as you don't need alternate markup--and let's face it, for most apps, HTML is all you need.

There are a few unfortunate situations where HTML tags that are nested inside JSF tags will render out of order. (This is a consequence of JSF being built on top of JSP.) But in practice, these situations can always be avoided.

Cheers,

Cay


Yeah, tables are good and all but if you need to tabulate dynamic data on a page, using a component for rendering said data in a table is much simpler than trying to mix JSTL iteration tags and JSF. It's cleaner too.

What I would like to see is a way to specify custom attributes. Something like....



I am sure it could be cleaner, but that was the first thing that popped into my head. OF course, there really is nothing stopping me from creating these components myself except for lack of ability to do so just yet.
Dave Wood
bronco
Ranch Hand

Joined: Aug 02, 2004
Posts: 161
It doesn't necessarily take care of this particular problem (wanting to control colspan), but it's worth knowing about the "verbatim" tag. You can do something like this:



Basically, this tag just lets you get around the problem of HTML showing up when rendering conditionally-rendered components. If your conditionally-rendered component needs to have non-JSF children, just wrap them in verbatim tags and they'll do the right thing (since the child will be a verbatim tag, not the HTML tags).

Unfortunately, if you have many of them, it can get pretty ugly (and your XML gets really invalid, if you care).

It would be really nice if there was a more compact form for this. Something like:

<h:v value="<div class='whatever'>" />

or

<h:div /> (which would require a BUNCH of tags to cover all of HTML)

...oh well!
[ December 21, 2004: Message edited by: Dave Wood ]

Co-Author of <a href="http://www.oreilly.com/catalog/jswing2" target="_blank" rel="nofollow">Java Swing</a><br />Co-Creator of <a href="http://www.sun.com/training/catalog/courses/CX-310-055.xml" target="_blank" rel="nofollow">SCJP 5.0</a> and <a href="http://www.sun.com/training/certification/java/associate_beta.xml" target="_blank" rel="nofollow">SCJA</a> exams
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSF rendering the whole page : Even the basic html tags
 
Similar Threads
Rendering JSF with XSL tags
Very stupid question about JSF
Problem with JSTL and RichFaces/JSF
JSF div tags
Mixing websites written in html and jsf