cancel
Showing results for 
Search instead for 
Did you mean: 

Question about "Enhancing Web Dynpro Table Performance in NW 04 SP Stack13"

Former Member
0 Kudos

Dear All,

After reading this article, my problem still does not get resolved. This article is talking about the actions when the lead selection remains unchanged. But my action is "FileDownload" UI table cell editor. My binary data is generated inside the code "onLeadSelection" event. How to implement the one trip-round event in FileDownload UI??? <b> You can explicitly declare an action for "LinkToAction" table cell editor, but what about "FileDownload"??? </b> Anyone has the idea??? Please share it with me.

thanks.

Zita

Accepted Solutions (0)

Answers (7)

Answers (7)

Former Member
0 Kudos

Hi Sergei,

thanks for your insight. The correct statement is :

wdContext.nodeTableData'().getNodeInfo().getChild("Resource").getAttribute("FileResourceTable");

But an error occurs (<b>java.lang.NullPointerException</b>

)when the binary file is saved to the "FileResourceTable" attribute. I have checked the binary data stored in out.toByteArray() which is not null.

wdContext.currentResourceElement().setFileResourceTable(out.toByteArray());

BTW, the Resource's parents node "TableData" with a cardinality 0..n

Do you know why this would be??

thanks alot.

Zita

roberto_tagliento
Active Contributor
0 Kudos

Again the problem could be because you try to access to one element that doesn´t exist!!!

You are doing:

wdContext.currentResourceElement()......

before do that insert at least one element, or try to access at the information you want without use "currentElement" methods.

Bye

Former Member
0 Kudos

Hi Bertram,

thanks for you answer. I have followed the instructions as u described.

I declared an inner, non-singleton(singleton set to false) cardinality 0..1 context node 'Resource' in the table node 'TableData' and an attribute 'FileResourceTable' of type binary in this inner node 'Resource'

but got the <b>java.lang.NullPointerException in wdDoInit()</b> in this line---

IWDAttributeInfo attInfo = wdContext.nodeResource().getNodeInfo().getAttribute("FileResourceTable");

Do you know the reason?

thanks.

Zita

roberto_tagliento
Active Contributor
0 Kudos

Could be because doesn´t exist at least one element?

This answer can seem strange, but for me can try.

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi zita

Please, use

IWDAttributeInfo attInfo = wdContext.getNodeInfo().getChild("Resource").getAttribute("FileResourceTable");

instead of

IWDAttributeInfo attInfo = wdContext.nodeResource().getNodeInfo().getAttribute("FileResourceTable");

BR

Sergei

Former Member
0 Kudos

Hi Bertram,

So by declaring the supply function, then I can use the compatabilityMode = NW04Plus thing now??

I will do the following things:

-Declare an inner, non-singleton, cardinality 0..1 context node 'Resource' in the table node 'TableData'

- Declare a supply function for this context node

- Declare an attribute 'File' of type binary in this inner node 'Resource'

- Implement the supply function: generate binary data here.

- change compatabilityMode to NW04Plus

- change table readOnly attribute to false

Do I miss anything to proceed??

thanks alot.

Zita

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Zita,

yes, my Validate-By-Rendering Technique can be used with the the compatabilityMode = NW04Plus interaction behavior (without implicit lead selection change).

Remeber, that the attribute 'File' of the non-singleton child node must be binary-modified.

Regards, Bertram

siarhei_pisarenka3
Active Contributor
0 Kudos

Hi Zita

Another technique in your case can be the following:

1. Use LinkToAction instead of FileDownload control.

2. When user clicks the link...

2.1 Obtain binary file content for the selected row in table.

2.2 Create CachedWebResource for the file content and get Url to the resource.

2.3 Create & open new External window with the Url.

I guess this technique will be even faster then to load file content for all visible rows. The only problem here is empty window that will left if user wants to download the file instead of just showing its content in browser.

BR

Sergei

Former Member
0 Kudos

Hi Bertram,

Thanks alot. But you are saying you work on NW04s?? What about my version NW04 SP13?? Does this solution apply to this version too?? <b>How will I handle the two-round trip of "FileDownload" element issue in NW04 SP13 then?</b>

thanks.

Zita

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Zita,

uups, I was too excited on the new On-Demand-Steam approach in NW04s that I missed the version detail in your thread header text.

The problem with FileDownload in NW04 Tables is, that resources must be stored in the context before the user clicks the FileDownload link on the UI. In addition, all resources must have the same MIME type. The FileDownload Link directly points to the Web Resource URL.

The only technique for reducing the context size (summed size of resources/byte arrays which are stored in all "table" node elements) I see is a <b>Validate By Rendering</b>. The (initial) memory reduction ratio of this technique is equal to <i>n_visibleRows/n_allRows</i>. This means in case you view a table with 5 visible rows and 100 lines you only have to store the 20th part of all resource in the context. With every table paging request the next chunk of 5 node elements gets validated by the Web Dynpro Runtime and the related resources are loaded to the context. In case the user pages the whole table the context will eventually store all resources and the inital memory reduction is lost.

<b>Solution: Validate by Rendering</b>

- Declare an inner, non-singleton, cardinality 0..1 context node 'Resource' in the table node 'TableData'

- Declare a supply function for this context node

- Declare an attribute 'File' of type binary in this inner node 'Resource'

- Implement the supply function: The supply function will be implicitly invoked by the Web Dynpro on-demand, this means as soon as the visible table rows are rendered and the affected/visible node elements are validated. The validation of the visible node elements in the node 'TableData' implies the validation of the inner non-singleton nodes 'Resource'.

In contrast to your approach the resources are not loaded to the context on <i>lead selection change</i> but on <u><i>visible table row rendering</i></u>.

Best Regards, Bertram

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Zita,

I'm currently writing/developing a new Web Dynpro Tutorial on File Upload/Download in NW04s. In this tutorial the topics "<b>Uploading Files in Tables</b>" and <b>"Downloading Files in a Table Using On-Demand Streams"</b> will be described in-depth.

Nevertheless I will answer your question here:

<b>Solution: Downloading Files in a Table Using On-Demand Streams</b>

1) <u>Context Definition</u>:

In a multiple context node define two context attributes

- <b>Resources</b>: of dictionary type "ddic:com.sap.ide.webdynpro.uielementdefinitons.Resource"

- <b>OnDemandStreamCalc</b>: <u>Calculated</u> Attribute (isReadOnly = true) of type "com.sap.tc.webdynpro.progmodel.api.IWDInputStream"

- a third attribtue <i>OnDemandResourceText</i> can be used to display a certain text (not equal to file name) in FileDownload UI element.

2) <u>Data Binding</u>:

Bind the <i>resource</i>-property of the FileDownload UI element to the context attribute <i>OnDemandResource</i>. The FileDownload UI element is a cell editor within a TableColumn of a Table. The Table is bound to the data node <i>Resources</i>.

3.) <u>Controller Coding</u>

- Populate Context Node (here in a supply function)

public void supplyResources(IPrivateTableView.IResourcesNode node, 
  IPrivateTableView.IContextElement parentElement)
{
  //@@begin supplyResources(IWDNode,IWDNodeElement)
  String calcAttrName =  
    IPrivateTableView.IResourcesElement.ON_DEMAND_STREAM_CALC;
  IPrivateTableView.IResourcesElement resourceElement;

  // ----------- 1. Resource Node Element ------------------------------ 
  resourceElement = wdContext.nodeResources().createResourcesElement();
  node.addElement(resourceElement);
  resourceElement.setOnDemandResourceText("SAP Logo - JPG Image");
  resourceElement.setOnDemandResource(
    WDResourceFactory.createResource(
      resourceElement.getAttributePointer(calcAttrName),
      "SAPLogo.jpg",
      WDWebResourceType.JPG_IMAGE));

  // ----------- 2. Resource Node Element ------------------------------
  ...

  //@@end
}

Implement Calculated Context Attribute Getter Method, <u>to stream the requested resource on demand</u>:

//@@begin javadoc:getResourcesDwldImgOnDemStreamCalc(
   IPrivateTableView.IResourcesElement)
/**
 *  Declared getter method for attribute OnDemandStreamCalc of node  
 *  Resources
 *  @param element the element requested for the value
 *  @return the calculated value for attribute OnDemandStreamCalc
 */
//@@end
public com.sap.tc.webdynpro.progmodel.api.IWDInputStream   
  getResourcesOnDemandStreamCalc( 
    IPrivateTableView.IResourcesElement element)
{
  //@@begin getResourcesOnDemandStreamCalc( 
  //  IPrivateTableView.IResourcesElement)
  // return IWDInputStream object for given on-demand resource, 
  // which is deployed in the same deployable object part 
  // (Web Dynpro Component 'FileUpDownloadComp').
  try {
    return this.getInputStream(
      wdComponentAPI.getDeployableObjectPart(),
      element.getOnDemandResource().getResourceName());
  } catch (FileNotFoundException e) {
    wdComponentAPI.getMessageManager().reportMessage(
      IMessageFileUpDownloadComp.FNF,
      new Object[] { element.getDwldImgOnDemResource().getResourceName()},
      true);
  } catch (WDAliasResolvingException e) {
      wdComponentAPI.getMessageManager().reportException(
        e.getLocalizedMessage(), true);
  }
  return null;  
  //@@end
}

- Implement helper method <i>getInputStream()</i> to retrieve IWDInputStream object, in this example from a deployed mime resource in the same component:

// @@begin others
/**
 * Returns an IWDInputStream object for a given resourceName in a 
 * deployable object part
 */
private IWDInputStream getInputStream(
  WDDeployableObjectPart deployableObjectPart, String resourceName)
  throws FileNotFoundException, WDAliasResolvingException {
  return WDResourceFactory.createInputStream(
    new FileInputStream(new File(WDURLGenerator.getResourcePath(
      deployableObjectPart, resourceName))));
}
// @@end

Regards, Bertram

Former Member
0 Kudos

The reason reading this article is that I try to prevent two-round trip of client server interaction time when the "FileDownload" cell editor is clicked. My version is in NW04 SP13. <b>So the new compatabilityMode = NW04Plus does not work for "FileDownload" element in NW04 SP13??? </b> thanks alot.

Former Member
0 Kudos

Zita,

AFAIK, in NW04 (even in latest SP-s) you have to populate content of download files in advance, i.e. you either load all files in memory (binary context attributes) in wdDoInit or must use onLeadSelect to populate binary attribute.

In NW04s FileDownload API is enchanced, so it is possible to avoid pre-loading of content and hence provides an option for new table selection behavior.

So, if you are on NW04 then just use good old (slow) onLeadSelect while new table selection model will force to preload huge amount of data in advance.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net