cancel
Showing results for 
Search instead for 
Did you mean: 

7.1: calculated ContextAttribute: getters are not generated

Former Member
0 Kudos

This relates to NW Mobile 7.1, development for PDAs, NWDS SP05 P01

In a view, I added an attribute to the context and marked it "calculated".

In its properties, I can see that there is a getter method assigned, but the stub with the UCA (user code area) is not generated in the java file. If I select "Goto Implementation F3" it is not there.

If I add it manually, it gets deleted on generation.

Bug or feature?

Cheers, Andre

Accepted Solutions (1)

Accepted Solutions (1)

stefan_henke
Contributor
0 Kudos

Hi Andre,

the supply function is always called if you trigger the reload() method of the context node. In your case if you call:

wdContext.noderewe1_sc().nodegetSomeTypes().reload();

You should execute the query in the way you described it in your posting. The corresponding supply function should contain the statement:

node.bind(Collections.singleton(getSomeTypes));

If the supply functions was implemented in that way and getSomeTypes is the query object available as global variable in the context class this should do the job. Please let me know if you face any specific issue with this implementation.

Regards,

Stefan

Answers (3)

Answers (3)

Former Member
0 Kudos

Hi Stefan,

yes, that is exactly what the rest of the code looks like.

Thanks for the explanation. Is there any documentation about this? I have not found any.

Your suggested solution already works for me

Cheers, Andre

Former Member
0 Kudos

Hi Stefan,

thank you for this excellent answer. It is good to know that a feature does not work and not that I am too stupid to use it correctly

But your answer rises a new question:

When is the supply function called? As far as I could see on during the initialization of the application and not every time I execute the query. The query I am using is called many times with changing parameters. I am setting the parameters in the method that is generated automatically.

Should I implement the fix, that you suggested, in this method?


	/**
	 * Method [getTypesForCatMakeDistinct].
	 */
	 	public void getTypesForCatMakeDistinct() {
//@@begin getTypesForCatMakeDistinct()
            TCurrentEquipElement equip = wdContext.nodeCurrentEquip().currentCurrentEquipElement();
            getSomeTypes.setPiCategory( equip.getEquipCategory() );
            getSomeTypes.setPiMake( equip.getEquipMake() );
            getSomeTypes.execute();
            wdContext.noderewe1_sc().nodegetSomeTypes().reload();
//@@end
	}

Cheers, Andre

stefan_henke
Contributor
0 Kudos

Hi Andre,

unfortunately, calculated attributes is an unsupported feature in 7.10 on PDA. In 7.11, it will be supported in the way you want to use it. Not sure if the following procedure could help in your case:

1) If you bound a DO node/DataStructure to the context, create an additional manual attribute

2) In your supply function for the context node, you can manually set the value for the additional attribute by calculating the value in the required way. You should loop over all the nodes you are going to bind to the context

These steps are a bit more complex during modeling time, but at least the result will be very similar to calculated attributes.

Regards,Stefan