cancel
Showing results for 
Search instead for 
Did you mean: 

How do I validate a cell in a dynamically generated table?

Former Member
0 Kudos

Hi experts.

Here is my problem.

I have a table with x rows and y columns. Each cell is an inputField. I would like to create a validator for each cell so that when enter is clicked, the action would validate the content entered. But without validating the rest of the row.

Since the columns are added dynamically, I cannot simply create an action for each column. I have no problems retrieving the current row being validated, but I can't figure out how to get the column. Is this available through the wdEvent? How do I do this?

Is there another smart way of doing this?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You could use a common (dispatch) action for all "InputField.onEnter" events. Using event parameter mapping, the table column ID may be passed to the action handler.

Armin

former_member182372
Active Contributor
0 Kudos

Hi Tomas,

Try to describe Armin`s suggestion more detailed:

1) Create action ("Action") in view with one string parameter ("id")

2) Assign action to all your columns:


public static void wdDoModifyView(IPrivateTestView wdThis, IPrivateTestView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
  {
	final IWDAction  onAction = wdThis.wdGetActionAction();
	final IWDTable table = (IWDTable)view.getElement("MyTableID");
	final IWDTableColumn[] columns = table.getColumns();
	for (int i = 0; i < columns.length; i++) 
	{
		final IWDTableColumn column = columns<i>;
		final IWDTableCellEditor cellEditor = column.getTableCellEditor();
		
		if (cellEditor instanceof IWDInputField)
		{
			final IWDInputField inputField = (IWDInputField)cellEditor; 
			inputField.setOnEnter( onAction );
			inputField.mappingOfOnEnter().addParameter( "id",  inputField.getId());
		} 
	}
  }

3) Implement validation logic in public void onActionAction(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, java.lang.String id )

Regards, Maxim R.

Answers (1)

Answers (1)

Former Member
0 Kudos

It works as described.

Thank you experts, points for everyone!