on 06-12-2007 4:14 PM
I am having this problem. when I attach a file and press submit button, it gave me
"Object could not be found in cache, key is null !"
In my ViewController context I have Invoice_DOC attribute (binary, fileupload)
and that is mapped to ComponentContoller.attribute(INVOICE_DOC).
here is wdDoInit() method of my view controller..
public void wdDoInit()
{
IWDAttributeInfo attInfo =
wdThis.wdGetDemurrageCompController().wdGetContext ().nodeSubmitElements().getNodeInfo().getAttribute(IPrivateDemurrageComp.ISubmitElementsElement.INVOICE_DOC);
IWDModifiableBinaryType binaryType = (IWDModifiableBinaryType) attInfo.getModifiableSimpleType();
}
Any Idea why I am having this..
I went through some tutorials, The controller node has cardinality of 1..1...
Hi,
Could you please try with the following code. Here I have an Action for file uploading.
public void wdDoInit()
{
//@@begin wdDoInit()
// get attribute info for context attribute "FileResource"
IWDAttributeInfo attributeInfo =
wdContext.getNodeInfo().getAttribute(
IPrivateFileUploadView.IContextElement.FILE_RESOURCE);
// make the context attribute's simple type modifiable.
// Only with this line of code the binary data (stored within the
// context attribute) can be parsed. The Web Dynpro Runtime stores
// the mime-objects metadata within the attributes type metadata.
attributeInfo.getModifiableSimpleType();
// set the file details invisible
wdContext.currentContextElement().setDetailsVisibility(
WDVisibility.NONE);
//@@end
}
//Another method for File upload button
public void onActionUploadFile(
com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent) {
//@@begin onActionUploadFile(ServerEvent)
// get attribute info for context attribute 'FileResource'
IWDAttributeInfo attributeInfo =
wdContext.getNodeInfo().getAttribute(
IPrivateFileUploadView.IContextElement.FILE_RESOURCE);
// get modifiable binary type from the attribute info,
// requires type cast.
IWDModifiableBinaryType binaryType =
(IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();
IPrivateFileUploadView.IContextElement element =
wdContext.currentContextElement();
// if a file in the 'FileResource' attribute exists
if (element.getFileResource() != null) {
try {
String mimeType = binaryType.getMimeType().toString();
byte[] file = element.getFileResource();
// get the size of the uploaded file
element.setFileSize(this.getFileSize(file));
// get the extension of the uploaded file
element.setFileExtension(
binaryType.getMimeType().getFileExtension());
// NOTE: context attribute 'FileName' must not be set
// because the FileUpload-UI-element property 'fileName'
// is bound to it. Consequently the fileName is automatically
// written to the context after file upload.
// set the details visibility attribute
element.setDetailsVisibility(WDVisibility.VISIBLE);
// report success message
wdComponentAPI.getMessageManager().reportMessage(
IMessageFileUpDownloadComp.SF_UPLOAD,
new Object[] { binaryType.getFileName()},
false);
} catch (Exception e) {
throw new WDRuntimeException(e);
}
}
// if no file in the 'FileResource' attribute exists
else {
// set the details visibility attribute, hide details
element.setDetailsVisibility(WDVisibility.NONE);
// report error message
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
msgMgr.reportContextAttributeMessage(
element,
attributeInfo,
IMessageFileUpDownloadComp.NO_FILE,
new Object[] { "" },
true);
}
// clear the FileResource context value attribute
element.setFileResource(null);
//@@end
}
Thanks
Chandan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well...not using attribute binding now in this case.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Garg,
Please have a look into thiese links.. hope these helps...
<a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=%2flibrary%2fwebdynpro%2fwdJava%2FWDTutorials%2FUploadingandDownloadingFilesinWebDynpro+Tables.pdf">Uploading and Downloading Files in Web Dynpro Tables</a>
and <a href="https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.highlightedcontent?documenturi=%2flibrary%2fwebdynpro%2fwdJava%2FUploadfileusingWebServiceinWebDynproJava+Application.pdf">Upload file using Web Service in Web Dynpro Java Application</a>
Hope these helps...
Please reward points if it helps..
Thanks and Regards
Avijit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That does not help
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.