cancel
Showing results for 
Search instead for 
Did you mean: 

how to validate table

Former Member
0 Kudos

Hai

how to validate record by record in a Table webdynpro.

if record is not satisfied condition raise the exception.

before records, which are satisfied condition those are send to save and invalidate.

eg:- table contain 3 fields .

filed1, filed2 ,field3.

all 3 fields are mandatory.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

this code helps you,

IPrivate<name>View.I<name>TableNode i<name>TableNode = wdContext.node<name>Table();

IPrivate<name>View.I<name>TableElement i<name>TableElement;

for(int i=0;i<i<name>TableNode.size();i++){

i<name>TableElement = i<name>TableNode.get<name>TableElementAt(i);

if(i<name>TableElement.get<field1>()!=null&&i<name>TableElement.get<field1>()!=null&&i<name>TableElement.get<field1>()!=null){

// save records

....

}else{

wdComponentAPI.getMessageManager().reportException(i<name>TableElement.getSno()":""fields are mandatory",false);

}

}

}

Regards,

ramesh

Former Member
0 Kudos

Hi Ramesh,

i tried ur code it is working but i want invalidate the records which are satisfied condition , i.e mandatory fileds are filled records.

i used the Invalidate() method .

after Save method statement.

it showing the java.lang.out of bound Exception.

how to invlaidate inserted records.

Former Member
0 Kudos

Hi,

observe the underline statement.

IPrivate<name>View.I<name>TableNode i<name>TableNode = wdContext.node<name>Table();

IPrivate<name>View.I<name>TableElement i<name>TableElement;

for(int i=0;i<i<name>TableNode.size();i++){

i<name>TableElement = i<name>TableNode.get<name>TableElementAt(i);

if(i<name>TableElement.get<field1>()!=null&&i<name>TableElement.get<field1>()!=null&&i<name>TableElement.get<field1>()!=null){

// save records

....

// remove this element from the node

i<name>TableNode.removeElement(i<name>TableElement );

}else{

wdComponentAPI.getMessageManager().reportException(i<name>TableElement.getSno()":""fields are mandatory",false);

}

}

}

Former Member
0 Kudos

hai Ramesh,

i doen what u tell..

if i entered one record it work fine . in case i entered 2 records it showing the error like..

java.lang.IndexOutOfBoundsException: I : 1, Size: 1

what to do.

Former Member
0 Kudos

post code ?

Former Member
0 Kudos

Hi Ramesh this is my code

IPrivateAddClientView.ICreateClientNode createClientNode = wdContext.nodeCreateClient();
    int nodeSize = createClientNode.size();
    String clientName = null;
    String region = null;
    String vertical = null;
 for(int i=0;i<nodeSize;i++)
  {
  	IPrivateAddClientView.ICreateClientElement TableElement = createClientNode.getCreateClientElementAt(i);
  	 	
  	if(TableElement.getClientName()!=null&&TableElement.getClientName()!="")
  	
  		{
  		clientName = TableElement.getClientName();
  		region= TableElement.getRegion();
  		vertical= TableElement.getVerticals();
  		
  	 wdThis.wdGetTaskManagerCompController().insertClient(clientName,region,vertical);
  	  wdContext.nodeCreateClient().removeElement(TableElement);
}
else{
	wdComponentAPI.getMessageManager().reportException(TableElement.getClientName()+":"+"fields are mandatory",false);  
	
	break;
	
		
}
  }

Former Member
0 Kudos

Hi,

code is fine !

in which line you getting the null pointer exception ?

possible post the code in wdThis.wdGetTaskManagerCompController().insertClient(clientName,region,vertical); method ?

Regards,

ramesh

Former Member
0 Kudos

HI

There might be some problem in your code at

wdThis.wdGetTaskManagerCompController().insertClient(clientName,region,vertical);

I think in insertClient method you are trying to add elements to a particular node. Try to check the code or post ur code in insertClient method. If it is fine then check the node cardinality.

Regards

Raghu

Former Member
0 Kudos

Hai Ramesh , Raghu.

thanks for for giving replies to my issue.

here the thing is when iam using invalidate or remove method in

loop . i am getting Exception

java.lang.Indexoutof bound Exception

to eliminate record in frontend which record is inserted .

with out using the Remove() method , every thing is working fine.

but after save we need to invalidate.

Former Member
0 Kudos

Hi,

may be problem in wdThis.wdGetTaskManagerCompController().insertClient(clientName,region,vertical);

method, from the error trace you can find the line number.

let me know in which statement it is showing the error or post the error trace ?

Former Member
0 Kudos

Hi Eswar,

Every thing is fine, but still you are getting error....

For me also i faced with simillar Error when removing element in for loop, but when i tried removing element in for loop in reverse order it worked fine..So Just try by iterating the for loop in reverse order while removing the element.

for (int i = wdContext.createClientNode.size()- 1; i >= 0; --i)

Coorelate this type of iteration as per your requirement, probably it may solve your answer.

Regards

Raghu

Former Member
0 Kudos

Yes Raghu....

it is working...

its some what happy...

Its working in reverse Manner..down to top.

It is not possible in top to down....

And one thing the Error records that how many of records are error those many lines of messages it showing , how can avoid instead of these many lines , for all error records in one message line.

is there any other way tell me..

my issue can resolve...

Former Member
0 Kudos

Hi Eswar,

Not sure what is ur problem, but try by using MessageArea UI element or Messagepool to generate Error message.

Regards

Raghu

Former Member
0 Kudos

Thanks a lot Raghu..

The main problem is out...

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi

go through this forums hope link u will get ur ans

Regards

Ruturaj

Former Member
0 Kudos

Hi Eswar,

You mean you want to delete or remove the record(element) that satisfies your condition and try to remove the element from the node.

Try this code in your button action

for(int i=0;i<wdContext.node<<abc()>>.size();i++)

{

if<<your condition>>

{

wdContext.node<<abc()>>.removeElement(wdContext.nodeabc().getabcElementat(i));

}

}

Regards

Raghu

Former Member
0 Kudos

Hai Ragu,

I tried u r code to eleminate record which is satisfied condition after method .

but result is if one record is entered in table.that everything is fine but in case many records entered in table.

In that case it raise the exception that is

Java.lang.Index out of Bound Exception

what is need to do ...

Former Member
0 Kudos

Hi,

If your exception is array out of bonds then check

your Node cardinality is 0..n and selection 1..n.

If your node is in component then you can change cardinality at component controller only.

and also check the table property-- selection is multi

Regards

Raghu

Former Member
0 Kudos

Hi

And also you need to put the above code in appropriate place. That is you should place the above code only after filling the node with complete data(or after binding all the elements to the node)

Try this,if not possible then revert me with detail post of your problem.

Regards

Raghu

Former Member
0 Kudos

HI,

If I understand your question correctly, You want to display the records which satisfy come condition. If yes, follow this code

for(int i=0;i<wdContext.node<TableNode>().size();i++)

{

wdContext.node<TableNode>().setLeadSelection(i);

if( ! ( wdContext.current<TableNode>Element().get<Field1>() <Condition>

&&

wdContext.current<TableNode>Element().get<Field2>() <Condition>

&&

wdContext.current<TableNode>Element().get<Field3>() <Condition> ) )

wdContext.node<TableNode>().removeElement(wdContext.current<TableNode>Element());

}

Regards

LN

Former Member
0 Kudos

Hi lakshmi Narayana ,

thanks for ur reply,

Your assume is right that is table is input fileds of 3 like above.

each filed is mandatory, i have one Method that is insert method.

My cod s as below but iam getting error ...

Null pionter Exception, some time Java.lang.indexoutof boundException.

what is the reason , help me on this .

for(int index=0;index<nodeSize;index++)
    {  
        if(wdContext.currentCreateClientElement().getClientName()!= null && 
    wdContext.currentCreateClientElement().getClientName()!= "" )
     {
     IPrivateAddClientView.ICreateClientElement createClientElement = createClientNode.getCreateClientElementAt(index);
		clientName = createClientElement.getClientName();
		region = createClientElement.getRegion();
		vertical = createClientElement.getVerticals();
		wdThis.wdGetTaskManagerCompController().insertClient(clientName,region,vertical);
		
		wdContext.nodeCreateClient().invalidate();

    }           
    else
    {
    	
    	wdComponentAPI.getMessageManager().reportException("enterclientname",false);
    	
    }
    	
	  }