cancel
Showing results for 
Search instead for 
Did you mean: 

How to addRecord in Web Dynpro to Model node (Entity Service ref)

Former Member
0 Kudos
71

Hi,

1) I create Entity Service in CAF and try to write web dynpro Table UI for it.

2) is it possible with using Model Node? or I MUST use Value Node - Table must have possibilities for Add, Edit and Delete records.

Now I can edit, and delete records, but I can't add records with AddRecord method

Code below

public void NewTS( )

{

//@@begin NewTS()

IServiceFacade serviceFacade;

// Add new Model object TS

ATS ts = TSServiceProxy.create();

ts.setDate( new Date(System.currentTimeMillis()));

ts.getAspect().sendChanges();

serviceFacade = CAFServiceFactory.getServiceFacade(tsDefinition.class);

// try to addRecord to Controller context

IWDNodeElement n = wdContext.nodeTS().createElement(ts);

wdContext.nodeTS().addElement(n);

}

The error is: com.sap.caf.rt.exception.CAFBaseRuntimeException:

Aspect row is invalid for aspect: <Aspect name="TS" >

Thx for any help

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nikolai,

I'm not sure here, but it seems the problem in typed access too.

Also possible that something wrong with nodes mapping.

Best regards,

Aliaksei.

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Nikolai,

implement it in the following way:

wdInit()

{

IAspect originalAspect = TSServiceProxy.FindByName(employee) ;

wdContext.nodeTS().bind(originalAspect)

//just create new attribute this java native type IAspect

wdContext.currentContextElement().setOriginalAspect() ;

}

public void NewTS( )

{

//@@begin NewTS()

IAspect originalAspect = wdContext.currentContextElement().getOriginalAspect() ;

IAspectRow newTS = originalAspect.createAspectRow() ;

newTS.setAttributeValue("date", new Date(System.currentTimeMillis())) ;

}

or

public void NewTS( )

{

IAspect originalAspect = wdContext.currentContextElement().getOriginalAspect() ;

IAspectRow newTS = originalAspect.createAspectRow() ;

ITSElement tsElem = wdContext.nodeTS().getTSElementAt(originalAspect.indexOf(newTS)) ;

tsElem.setAttributeValue("date", new Date(System.currentTimeMillis())) ;

}

Best regards,

Aliaksei

Former Member
0 Kudos

Hi Aliaksei,

After

IAspectRow newTS = originalAspect.createAspectRow() ;

I received

The error is: com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: read access to model attribute code failed

Former Member
0 Kudos

Hi Nikolai,

How you supplied your model node initially ?

Did you bind an aspect in the following way:

node.bind(myAspect) ;

In this way the ts aspectrow could not be added as you implemented, because it refernce different aspect instance. You could create your ts aspect row in initial myAspect without explicit coding :

IWDNodeElement n = wdContext.nodeTS().createElement(ts);

wdContext.nodeTS().addElement(n);

the changes will be automatically applied on your model node.

Best regards,

Aliaksei.

Former Member
0 Kudos

Hi Aliaksei,

I'd like to select TimeSheets (TS) for employee and then to add a new TS to the selection (for this employee).

In order to do that in wdDoInit I use

// bind component controller context node TS to

// TS Entity Service

wdContext.nodeTS().bind( TSServiceProxy.FindByName(employee));

How to "create your ts aspect row in initial myAspect" in this case?

jan_rauscher
Advisor
Advisor
0 Kudos

Hello,

why don't you use one of the UI patterns, e.g. the Property Editor Pattern? Please find here a description how it can be used:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/9ed828c2-0701-0010-ba8f-89d90a594f31">Property UI pattern</a>

Regards,

Jan

Former Member
0 Kudos

My UI is too complex for UI patterns, and I use WD for it