cancel
Showing results for 
Search instead for 
Did you mean: 

TableFilter not working for values with breaks and tabs

Former Member
0 Kudos

Hi,

I have implemented table filter using the tablefilter.java class from the blog [TableFilter|http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/5350] [original link is broken] [original link is broken] [original link is broken] [original link is broken];

I am using NWDS04 version and the Table Filter functionality is working fine except for filtering content with breaks, tabs.

Example Scenario:

Data entry into a SQL table is done using a separate create data webdynpro java application and the data from the SQL table is displayed using table UI in a list/display application.

In the create Data application users can input data using input field UI and for one field we have used TextEdit UI where users can enter lengthy data using line breaks or tabs.

User enters data in Create Application TextEdit UI in the format with line breaks

"Cement

Supplies"

The Data gets stored in SQL table using line breaks in the following format

"cement supplies"

When it appears in Webdynpro java table UI it appear as "Cement Supplies". When i try to filter the column using the search criteria "c" or "s" or "cement" or " supplies" or "Cement Supplies" filter class is not considering the value with line breaks and it completely ignores it and only displays the other records in the table with matches the filter condition entered. Even after removing the filter criteria the particular record is missing and only when i refresh the table content i am able to view the record in the table again.

Please guide me on this table filter issue.

Regards,

Bala Baskaran.S

Accepted Solutions (1)

Accepted Solutions (1)

former_member185879
Active Contributor
0 Kudos

Hello Bala,

I feel In Filter Class we dont have a option to eliminate the special characters, either you want to implement it in filter class or in your dynpro component before calling this filter class method.

You try the following code to change the special characters and then call the filter class method.

String Text = "";

Text = wdContext.nodeABC().getABCElementAt(i).getTextValue().toString().trim();

Pattern Pnewline , PcarriageReturn ;

Matcher Mnewline ,MCarriageReturn ;

Pnewline = Pattern.compile("\n");

Mnewline = Pnewline.matcher(Text );

String Text_Data = Mnewline.replaceAll(" ");

PcarriageReturn = Pattern.compile("\r");

MCarriageReturn = PcarriageReturn.matcher(Text_Data);

Text_Data = MCarriageReturn.replaceAll(" ");

wdContext.nodeABC().getABCElementAt(i).setTextValue(Text_Data);

In this way you can change the Special charactes in the text. Sometime replaceAll will not work, thats the reason Pattern and Matcher are used.

May be in your case run a for loop for the node and change the format of the attributes. Also you should do this loop for Orignial Source node and not for the datasource node.

Try and Reply.

Regards

Nizamudeen SM

Answers (2)

Answers (2)

Former Member
0 Kudos

Dear Nizam,

Thank you ... The filter problem is resolved for records with line breaks with the help of you code.

Line break in records gets stored in SQL database as \r\n.

Used the below method to replace the \r\n in the originalNode source before passing to the filter class. Now the table filter will be able to filter records with line breaks.

public void changepattern( )
  {
    //@@begin changepattern()  
    
	for(int i=0;i<wdContext.nodeOriginalSrc().size();i++)
    { 
		    String place = "";
			place = wdContext.nodeOriginalSrc().getOriginalSrcElementAt(i).getPlace().toString().trim();
			Pattern Pnewline , PcarriageReturn ;
			Matcher Mnewline ,MCarriageReturn ;
			Pnewline = Pattern.compile("\n");
			Mnewline = Pnewline.matcher(place);
			String place_Data = Mnewline.replaceAll(" ");
			PcarriageReturn = Pattern.compile("\r");
			MCarriageReturn = PcarriageReturn.matcher(place_Data);
			place_Data = MCarriageReturn.replaceAll(" ");
			wdContext.nodeOriginalSrc().getOriginalSrcElementAt(i).setPlace(place_Data); 
			 	
			String age = "";
			age = wdContext.nodeOriginalSrc().getOriginalSrcElementAt(i).getPlace().toString().trim();
			Pattern Pnewline1 , PcarriageReturn1 ;
			Matcher Mnewline1 ,MCarriageReturn1 ;
			Pnewline1 = Pattern.compile("\n");
			Mnewline1 = Pnewline.matcher(age);
			String age_Data = Mnewline1.replaceAll(" ");
			PcarriageReturn1 = Pattern.compile("\r");
			MCarriageReturn1 = PcarriageReturn1.matcher(age_Data);
			age_Data = MCarriageReturn1.replaceAll(" ");
			wdContext.nodeOriginalSrc().getOriginalSrcElementAt(i).setPlace(age_Data);
    }   
    
    //@@end
  }

public void onActionfilter(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
  {							
	wdThis.changepattern();
	wdContext.currentTablefilterElement().getFilter().filter(wdEvent,wdContext.nodeTableSrc(),wdContext.nodeOriginalSrc(),
	wdContext.nodeTableFilter(),wdComponentAPI.getMessageManager());
    //@@end
  }

Regards,

Bala Baskaran.S

Former Member
0 Kudos

Hi,

I think you can format the text enterted in the TextEdit UI for necessary page breaks by code before writing to the Database.

When you retrieve the data, it'll be in the same format also..

Regards,

Vijay.