Topic
  • 6 replies
  • Latest Post - ‏2012-03-06T22:11:26Z by SystemAdmin
TammyDix
TammyDix
6 Posts

Pinned topic JSF custom file upload tag developed with JSF1.1 is not working in JSF1.2

‏2012-02-22T20:31:29Z |
We have a custom file upload tag developed in our JSF application. Here is how it appears in the JSP file.


<at:attachmentTable value=
"#{Diagrams.diagram.deploymentDiagrams.attachmentList}" remove=
"#{Diagrams.deployment.removeAttachment}" /> <h:message for=
"deployment" styleClass=
"errorMessage"/> <at:attachmentAdd id=
"deployment" name=
"deployment" pageName=
"diagramsEdit" value=
"#{Diagrams.diagram.deploymentDiagrams.attachmentList}"/>


We are trying to migrate this application from WAS6.1 and JSF1.1 to WAS8.0 and JSF1.2 Sun RI. Everything is working ok except for this file upload tag.

On all our pages we have a back button. Now any page that has this file upload custom tag, when we try to click on the back button on that page, the page goes blank and the logs throw a NullPointerException. After debugging I find that the error is thrown from the AttachmentAddRenderer class.


Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap(); Map map = context.getExternalContext().getRequestMap(); String componentName = (String) component.getClientId(context); String commentName = (String) component.getClientId(context) + 
"Comment"; String comment = requestMap.get(commentName); String fileuploadKey = (String) component.getClientId(context); String pageName = (String)component.getAttributes().get(
"pageName"); map.put(
"pageName", pageName); map.put(
"name", componentName); component.getValueExpression(
"comment").setValue(context.getELContext(), comment); Map fileMap = (Map)context.getExternalContext().getRequestMap().get(
"com.ibm.faces.FileItemMap"); com.ibm.faces.fileupload.util.ContentElement file = (com.ibm.faces.fileupload.util.ContentElement)fileMap.get(fileuploadKey); HtmlFileupload upload = 

new HtmlFileupload(); upload.setFilename(file.getFileName().replaceAll(
"\"", 
"")); upload.setMimetype(file.getMimeType()); component.getValueExpression(
"fileupload").setValue(context.getELContext(), upload); 

byte[] bytestream = file.getContentValue(); component.getValueExpression(
"bytestream").setValue(context.getELContext(), bytestream); 

if (bytestream != 

null && bytestream.length > 0 && component 

instanceof UIInput) 
{ UIInput input = (UIInput)component; input.setSubmittedValue(bytestream); input.setValid(

true); 
}


What I dont get is the reference to "com.ibm.faces.FileItemMap" in the above code. I have no idea what this part of the code is looking for. Does anyone know of this issue? When I debug and spit the requestMap values from our existing WAS6.1, JSF1.1 application I see that there is a value for the key "com.ibm.faces.FileItemMap" but when I do that for WAS8.0 and JSF1.2 I dont see it returning any value and when the code at line

com.ibm.faces.fileupload.util.ContentElement file = (com.ibm.faces.fileupload.util.ContentElement)fileMap.get(fileuploadKey);

is executed, the fileMap is null and hence I get the NullPointerException.

I have been trying to figure this out for the last 4 days with no success. If anyone has any idea about this, please give me pointers. That would be very helpful.

Thank you in advance for all your help in this matter.

Tammy
Updated on 2012-03-06T22:11:26Z at 2012-03-06T22:11:26Z by SystemAdmin
  • TammyDix
    TammyDix
    6 Posts

    Re: JSF custom file upload tag developed with JSF1.1 is not working in JSF1.2

    ‏2012-03-02T14:07:38Z  
    Update to my scenario.

    I am working on a project to migrate an application from the existing WAS6.1, JSF1.1, Java1.5 to WAS8.0, JSF1.2 and Java1.6 environment. We have run into an issue with a custom file upload component that is not working in the new environment. Here are the details.

    What is happening
    When we access any page that has this custom component, it renders ok. But if we try to navigate away from this page such as click on the back button or click on any top menu items, the page just goes blank.

    Few things that we found when we debugged
    1. When you try to navigate away from this page, the appropriate method needs to be called in the backing bean, like cancel() when you click the back button, but it never gets called.
    2. The decode method in the custom render class throws an exception when the upload file details are accessed in the request scope. My previous thread gives the details.

    Here is what we tried
    We cleaned up the jsp with the custom tag and instead used the hx:fileupload tag. When we tried to perform the same actions mentioned above we got a faces exception which you will find in the attached text file.

    So in short the hx:fileupload tag also does not function correctly. Just to make sure, I tried doing the same in our current WAS6.1 environment and all worked as it should.

    We have been trying to resolve this for the last 2 weeks with no success. Please give me pointers to any known issues if exist or if I need to make changes to my existing way.

    Any help will be greatly, greatly appreciated. We have a deadline on this hence the urgency.

    Thanks.
    TD
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: JSF custom file upload tag developed with JSF1.1 is not working in JSF1.2

    ‏2012-03-02T15:38:01Z  
    • TammyDix
    • ‏2012-03-02T14:07:38Z
    Update to my scenario.

    I am working on a project to migrate an application from the existing WAS6.1, JSF1.1, Java1.5 to WAS8.0, JSF1.2 and Java1.6 environment. We have run into an issue with a custom file upload component that is not working in the new environment. Here are the details.

    What is happening
    When we access any page that has this custom component, it renders ok. But if we try to navigate away from this page such as click on the back button or click on any top menu items, the page just goes blank.

    Few things that we found when we debugged
    1. When you try to navigate away from this page, the appropriate method needs to be called in the backing bean, like cancel() when you click the back button, but it never gets called.
    2. The decode method in the custom render class throws an exception when the upload file details are accessed in the request scope. My previous thread gives the details.

    Here is what we tried
    We cleaned up the jsp with the custom tag and instead used the hx:fileupload tag. When we tried to perform the same actions mentioned above we got a faces exception which you will find in the attached text file.

    So in short the hx:fileupload tag also does not function correctly. Just to make sure, I tried doing the same in our current WAS6.1 environment and all worked as it should.

    We have been trying to resolve this for the last 2 weeks with no success. Please give me pointers to any known issues if exist or if I need to make changes to my existing way.

    Any help will be greatly, greatly appreciated. We have a deadline on this hence the urgency.

    Thanks.
    TD
    Hello, there was a problem with the hx:FileUpload library that caused a similar exception. It has been fixed already. I am currently investigating how you can obtain this fix, I will post again as soon as I have this information.

    Regards
    Victor
  • TammyDix
    TammyDix
    6 Posts

    Re: JSF custom file upload tag developed with JSF1.1 is not working in JSF1.2

    ‏2012-03-06T15:20:38Z  
    Hello Victor,

    I was writing to find out if you had a solution to our file upload tag issue. We have a deadline of March 21st and hence my query. Please let me know as soon as possible when and how the fix can applied.

    Thanks.
    Tammy
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: JSF custom file upload tag developed with JSF1.1 is not working in JSF1.2

    ‏2012-03-06T15:38:24Z  
    • TammyDix
    • ‏2012-03-06T15:20:38Z
    Hello Victor,

    I was writing to find out if you had a solution to our file upload tag issue. We have a deadline of March 21st and hence my query. Please let me know as soon as possible when and how the fix can applied.

    Thanks.
    Tammy
    Hello Tammy,

    It would be good to confirm if you have the problematic version of the library before sending you into a process to find a fix that might not be what you need. Please copy to another folder the jsf-ibm.jar, located inside the WEB-INF/lib directory of your project, extract the contents with a zip utility, open the MANIFEST.MF file under the META-INF directory and look for the value under "Implementation-Version:".

    The known issue I told you before is found in versions JWL v3_1_11 and JWL v3_1_12.

    Please let me know what is the version you are using.

    Regards.
  • TammyDix
    TammyDix
    6 Posts

    Re: JSF custom file upload tag developed with JSF1.1 is not working in JSF1.2

    ‏2012-03-06T15:45:47Z  
    Hi Victor,

    Below is what my MANIFEST.MF file has from the jsf-ibm.jar:
    
    Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: IBM Corporation Specification-Title: Java Server Faces Implementation-Title: JSF Widget Library (JWL) - Base Implementation-Version: JWL v3_1_12 Implementation-Vendor: IBM Build-Version: 20111011.1036 Build-Date: October 11 2011 Copyright-Info: Copyright (c) 2003,2008, International Business Machin es Corporation.  All Rights Reserved.
    


    So yes from what you are indicating we are using the jars that have the problem.

    Thanks.
    Tammy
  • SystemAdmin
    SystemAdmin
    6420 Posts

    Re: JSF custom file upload tag developed with JSF1.1 is not working in JSF1.2

    ‏2012-03-06T22:11:26Z  
    • TammyDix
    • ‏2012-03-06T15:45:47Z
    Hi Victor,

    Below is what my MANIFEST.MF file has from the jsf-ibm.jar:
    <pre class="jive-pre"> Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.2 Created-By: IBM Corporation Specification-Title: Java Server Faces Implementation-Title: JSF Widget Library (JWL) - Base Implementation-Version: JWL v3_1_12 Implementation-Vendor: IBM Build-Version: 20111011.1036 Build-Date: October 11 2011 Copyright-Info: Copyright (c) 2003,2008, International Business Machin es Corporation. All Rights Reserved. </pre>

    So yes from what you are indicating we are using the jars that have the problem.

    Thanks.
    Tammy
    Hello again,

    The next step is to contact IBM Rational support so they provide you with the latest IBM JSF Widgets Library version containing the fix to your problem. Mention the following technote so they know there is already a fix for this.

    http://www-01.ibm.com/support/docview.wss?uid=swg21584996

    I hope your issue is resolved soon. Regards.