Skip to main content

dojo tabbedview in a JSF page

4 replies [Last post]
jackett_dad
Offline
Joined: 2007-07-18
Points: 0

I want to use dojo's tabbedview in a JSF page, but currently I cannot get it to work. I was able to bring up the table and inlineedit objects, which are clearly documented as being two of three that work in JSF.

I see this error:

Error loading jmaki.widgets.dojo.tabbedview.Widget : id=j_id37
Script: http://localhost:8080/proserver/jsfadmin/pages/main/startup.jsf (line:41).
Message: 'message' is null or not an object

There is an Ed Burns blog entry that talks about modifying widget code so that it will function properly. I tried to follow those guidelines by modifying the component.js of tabbedview in two places where a bind was occuring. I'm sure I didn't do it right, but I get the same exact error after the modifications as before.

Can tabbedview be used, converted, or has it been converted by somebody else yet?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jackett_dad
Offline
Joined: 2007-07-18
Points: 0

I've got a much better picture of what my problem is.

I am running not just a JSF application, but a Facelets application as well. The reason I like Facelets is for it's built in templating capability. I'm also taking advantage of the quick and easy way I can write taglibs as xhtml.

I started with your dojo application that demos all the dojo widgets in a jsf application. Then I tried the yahoo widgets as well. I started another thread with a report on what happened there, but I can use the yahoo widgets I think and will be able to use IE as a client as well as Firefox which seems to be flawless.

I set up the yahoo widget demo app in my environment and it worked. But as soon as I set the view handler in faces-config.xml as such:



en

com.sun.facelets.FaceletViewHandler

I can no longer view any of the jsp pages because of this error:

javax.servlet.ServletException: Error Parsing /tabbedview-jsf.jsp: Error Traced[line: 1] The markup in the document preceding the root element must be well-formed.
javax.faces.webapp.FacesServlet.service(FacesServlet.java:249)

So do I have to scrap the notion of Facelets in order to use jmaki? I'm early enough into the project to make that call, but that would not be the ideal.

Ideally, I could use strictly xhtml and not have to bother with JSP at all, but I've tried to use the widgets in XHTML, and there are problems that I could enumerate if need be, but I have a feeling that this avenue hasn't been fully developed. I could be wrong.

The reply to this will shape my ongoing direction on this project. If Facelets and jMaki can't mix, then I will have to abandon one or the other, and at this juncture, I would have to get rid of facelets and stay with the jsp/jsf mix.

With facelets/xhtml/jmaki, I don't have to upgrade my version of Tomcat, which is 5.5, because I wouldn't have to have 2.1 jsp compliance.

jackett_dad
Offline
Joined: 2007-07-18
Points: 0

I am altering the yahoo app so that it uses xhtml and facelets like I would ultimately like to see this work. I could war the application when I am done if you would like a copy. This would include all the jars in web-inf\lib so that it is all inclusive and ready to run.

I am going to use this application as proof of concept to my manager. As it stands this morning, migration to Tomcat 6 is not an option, so I can't use the jsp example application as a start. I have no choice but to make do with what widgets work today, develop my own (which may or may not happen in the near future), or simply not use widgets and do things the hard way.

In the mean time, I would be happy to provide an example application that demonstrates the problems I am having as well as shows what I am using that works as expected.

gmurray71
Offline
Joined: 2003-07-31
Points: 0

Hi Jackett_dad,

I don't think the widget is being set up correctly. I would suggest you look at the JSF Dojo or the JSF yahoo tabbed view examples in our test application which can both be found here:

https://ajax.dev.java.net/servlets/ProjectDocumentList?folderID=6844&exp...

Generally your pages are going to look lie the following:

<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsf" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Dojo Tabbed View Test</title>
</head>
<body>
<h2>Dojo Tabbed View Test</h2>
<a href="index.jsp">Back to Samples</a>
<hr>

<div style="height:300px">
<f:view>
<a:widget name="dojo.tabbedview"
value="{tabs:[
{label:'Tab 1', include : 'tab1-jsf.faces'},
{label:'Tab 2', include : 'tab2-jsf.faces'},
{label:'Tab 3', include : 'tab3-jsf.faces'},
{label:'Static Tab', content: 'Tab 2 Content'} ]}" />
</f:view>

</div>
</body>
</html>

The seperated JSF pages mapped to by the include properties may also contain JSF components.

For example tab1-jsf.jsp (mapped to in the first tab) looks like the following:

<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsf" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<h1>Table Tab</h1>

<f:view>
<a:widget name="dojo.table" />
</f:view>

You will need to have your jmaki resources in the /resources/dojo directory or you can include a jar file incliding these resources in your WEB-INF/lib directory. This jar files are included in the test web applicaitons if you want to get them.

Let us know if you have a hard time understanding the test applications.

Also if you could post the JSF markup you are using that would help too.

Thank you,

-Greg

Message was edited by: gmurray71

jackett_dad
Offline
Joined: 2007-07-18
Points: 0

Greg,

Your reply has had me working all day. I was using pure xhtml pages and no jsp extensions. I have been finding in the examples that when I use jsp pages, there is never any problem with the widgets.

I am trying to get my web application to interepret my jsp pages through the faces servlet, but I am having problems.

In web.xml, I have the following entry:


newadmin
*.jsf

newadmin is my FacesServlet

My main page is tabbedview.jsp:

<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsf" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

"http://www.w3.org/TR/html4/loose.dtd">




JSP Page

Tabbed View Demo


value="{items:[
{label : 'Tab 1 - Yahoo Tree', include : '/jsfadmin/pages/jmaki/tab1.jsf' },
{label : 'Tab 2 - Yahoo Button', include : '/proserver/jsfadmin/pages/jmaki/tab2.jsf' },
{label : 'Tab 3 - Dojo Tree', include : 'tab3.jsf' }
]
}" />


I'm experimenting with how exactly to refer to the tab sources. All my pages ( tabbedview.jsp, tab1.jsp, tab2.jsp, and tab3.jsp) are located in /jsfadmin/pages/jmaki.

tab1.jsp looks like this:

<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsf" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

Tab 1


value="{
root : {
label : 'Yahoo Tree Root Node',
expanded : true,
children : [
{ label : 'Node 1.1'},
{ label : 'Node 1.2',
expanded : true,
children : [
{ label : 'Node 3.1',
action : { topic : '/foo/select', message : {targetId : 'bar'}}
}
]
}
]
}
}"/>

I try to access this page by the address: http://localhost:8080/proserver/jsfadmin/pages/jmaki/tabbedview.jsf, but I get an HTTP 404, saying The requested resource (/proserver/jsfadmin/pages/jmaki/tabbedview.jsf) is not available.

If I try accessing it directly by using the jsp extension, I get java.lang.NoClassDefFoundError: javax/servlet/jsp/tagext/JspIdConsumer

I realize this isn't the forum for these kinds of questions, as jmaki hasn't become involved yet. I'm posing this question somewhere else at the same time, but this is, in my mind, the last stumbling block. I was able to see the tabbed view when I was using the xhtml extension, but then I had problems with the widgets themselves that, according to other experimentation, I wasn't seeing when the page was a JSP.

Remember, I am working with Tomcat 5.5x, in case that matters.

I'll be back if I work this out, but I again want to thank you for your input here. It gave me a lot to try. There was a problem with the dojo/jsf war that I had, in that it could not find the facesservlet. I added the faces jars from jsf 1.2 (jsf-impl and jsf-api) to web-inf/lib, but that didn't fix the problem for some reason.

Argghhh.