开发者

rich:fileUpload within GateIn portlet

Environment: RichFaces 3.3.3 Final; Facelets 1.1.15; JBoss portletbridge 2.1.0 Final; GateIn Portal 3.1.0 as bundled with JBoss AS 5.1 and the Mojarra JSF 1.2 which is built in.

Some code snippets: filepage.xhtml:

 <a4j:form id="fileForm">
      <rich:fileUpload fileUploadListener="#{testBean.fileListener}"
        acceptedTypes="txt" maxFilesQuantity="1" />
      <!-- etc. -->
 </a4j:form>

TestBean.java:

 public void fileListener(UploadEvent e) throws IOException {
    System.out.println("Entering the fileListener Method");
    UploadItem item = e.getUploadItem();
    File file = item.getFile();
            // etc...
}

Result when deployed as a stand-alone web app is as expected, the component displays, user clicks add, browses then selected a file, file is added to the list, user clicks upload button, and the line "Entering the fileListener Method" displays on the console (along with other things ha开发者_Python百科ppening).

Result on GateIn: All of the above EXCEPT the sysout and other code in the listener. It appears that this method is not getting called.

I have already spent a few days reading through JBoss community forums and a few JIRAs, and it seems my problem is not new. I tried each of the suggestions I found, but none worked for me. Also, none of these posts were more recent than Jan 2010, and all of the constituent parts of my app have had new versions since then.

Your assistance, or a pointer to up-to-date and detailed information, is greatly appreciated.


I do not consider this an answer to my own question, but this is too large for a comment and I do not want to influence answers by adding this as an edit. Anyway, at a suggestion from a colleague, I have a work-around of sorts.

As I mention in the question, the file upload works perfectly within a stand-alone web-app, so why not make the portlet merely POINT TO that web-app, rather than BE that web-app.

In portlet.xml, change the <portlet-class> from javax.portlet.faces.GenericFacesPortlet to a java portlet you create, say mypackage.DispatchPortlet. Also remove the <init-param> with defaultViewId's.

The DispatchPortlet is in the same project as the everything else, and is barely a step more complex than the entry HelloWorld portlet. Just override doView and add these four little lines:

 response.setContentType("text/html");
 PrintWriter out = response.getWriter();
 out.println(HTML_CONTENT);
 out.close();

HTML_CONTENT is a static String variable that looks a little like:

 <iframe src="url to your app" height="400" width="600">no iframes</iframe>

That's litterally all it takes. One almost wonders why we bother having a portlet bridge. Not only does everything work, but it also looks a little better because some of the funky stuff GateIn does to CSS doesn't happen.

However, I consider this a ghetto solution and am really looking for the right way to make this a 100% portlet, with functioning file upload.


I located in the documentation for Red Hat EPP that file upload is not supported. Perhaps when the next version is ready (to support JSF 2, Richfaces 4, and Bridge 3) then it will be, but for now, the work-around is the only choice.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜