cancel
Showing results for 
Search instead for 
Did you mean: 

Problem in Two Column Table

Former Member
0 Kudos

Hi,

I am creating two column table in WD. In first column i have bind the values through context(wdDoInit). Second column will display the parsed value when a button is clicked.

My problem is when the onAction event gets triggered the first column gets disappeared.

First column should be stable according to my requirement.

Please provide suggestion

Regards,

krish

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Krish,

It would be better if you put your code that is written in the wdinit() for display of data in 1st columbn in wdModifyView() because wdInIt() method is called whenever a view is instantiated but wdModifyView() is called whenever the view is modified.

While you are populating the data in second column the view is getting modified and as during this modification the wdInIt() is not referenced hence the data is getting flushed from 1st column.

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

what I understood from you code is you are creating an element of the same node MonthOfYear twice once in wdInIt() and then once under action.

this may override the node data...

you can create a global element for the node MonthOfYear and then add elements to the node both under wdInIt() and under the action.

Former Member
0 Kudos

Hi,

The code for the first column if placed in wdDoModifyView the second column is not displaying the values after the action is triggered.

If the code is placed in onAction block only the second column is displaying the values.

Regards,

Krish

Edited by: Krish Krish on Oct 23, 2008 8:40 AM

Former Member
0 Kudos

The suggestions to place that code in wdDoModifyView() are nonsense.

Probably you are recreating the node elements in the action handler but not setting the attribute value displayed in the first column.

Could you please post your code?

Armin

Former Member
0 Kudos

sorry for the delayed response... i 've added the code for wdDoInit and onAction method

public void *wdDoInit*()
  {
    //@@begin wdDoInit()

    
	/*
	 * column1 
	 */
String[] col_val = new String []
		 {

			"TargetTestTool", "Version", "UserInterface", "BusinessLogic",
			"Interface", "UI_controls" 
		 };

	//	1. Create context elements for node "MonthsOfYear"
		 List val_list = new ArrayList();
		 for (int i =  0; i < col_val.length; ++i)
		 {

		 IPrivateFileUploadView.IMonthsOfYearElement val = wdContext.createMonthsOfYearElement();

		 val.setValue1(col_val<i>);
		 val_list.add(val);

		 }

	//	2. Bind node to element list
		 wdContext.nodeMonthsOfYear().bind(val_list);
		 
		 

	//	3. Initialize selection
		for (int  i = 0;  i < wdContext.nodeMonthsOfYear().size(); ++i)
		{

	//select summer months
			wdContext.nodeMonthsOfYear().setSelected(i, i>=5 && i<=7 );
		}

	//	set lead selection

		wdContext.nodeMonthsOfYear().setLeadSelection(5);
		 		 
	
    }


public void *onActionUploadFile*(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {
    //@@begin onActionUploadFile(ServerEvent)
		// TODO FileUpload - Step 2: onActionUploadFile()
		
	
		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();

		String file_name = element.getFileName();
		//			String str = x( file_name );

		Vector data = x(file_name);
		
	
	

		
		///COLUMN2
		
		String[] monthNames = new String[data.size()];
		for (int i = 0; i < monthNames.length; i++) {
			monthNames<i> = data.get(i).toString();
		}

		//	  1. Create context elements for node "MonthsOfYear"
		List monthsOfYear = new ArrayList();
		for (int i = 0; i < monthNames.length; ++i) {

			IPrivateFileUploadView.IMonthsOfYearElement month =
				wdContext.createMonthsOfYearElement();

			month.setMonthName(monthNames<i>);
			monthsOfYear.add(month);

		}

		//	  2. Bind node to element list
		wdContext.nodeMonthsOfYear().bind(monthsOfYear);

		//	   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));
				element.getFileName();

				
					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 & Regards,

Krish

Former Member
0 Kudos

Hi,

Instead of creating elements in file upload try to iterate through the existing elements and assign value the monthName attribute.

Regards

Ayyapparaj

Former Member
0 Kudos

I am a little bit speechless. Is this your production code? You copied this sample code from the online help that I wrote 5 years ago including the comments that have nothing to do with your application and pasted it into your class?

Armin

Former Member
0 Kudos

Hi,

Yes you can do that in wdmodifyview or in action button. If you want to see the first col details when view is intantiated. Then you have your code both in wdinit() as well as in wdmodifyview()

Regards

Raghu

Former Member
0 Kudos

Hi Krish,

Write the code of setting the values in the first column in your wdDoModifyView() method or in the beginning of the action which is getting called on click of the button.

Hope this may help you.

Regards,

Swati

Former Member
0 Kudos

Hi,

Can u explain your problem in detail. Becauze I cld not get how a table col binded to context will disapear on action?

Regards

Raghu

Edited by: Raghunandan Madarikuruva on Oct 23, 2008 8:46 AM

Former Member
0 Kudos

Thanks Raghunandan,

The first column will display a set of constant values for which i have written the code in wdDoInit function.

The second column will display the parsed values from a XML file when a button is clicked for the coding has been written in onAction coding block.

Once the application starts running the values are getting displayed in first column once the button is clicked the first column gets disappeared and displays the corresponding values for second column.

This is my issue.

Thanks in advance