cancel
Showing results for 
Search instead for 
Did you mean: 

Read a View Context's node's element and assign from Component controller

Former Member
0 Kudos

Hello Experts,

I'm new to JAVA WD.

Here is my scenario.

I have to use an Adobe form in a WDJ. The input parameters and the output parameters of the DC are defined in a method in the Interface Controller method.

The context of the Component Controller has the following structure

Context

---StartDate

---EndDate

---AbsenceType

Then the mapping between the Component controller and the interface controller is done so that the Interface controller also has the context structure as

Context

---StartDate

---EndDate

---AbsenceType

So now the interface controller and the component controller are bounded correctly.

Now I bind the view also with the Component controller as below.

Context

---StartDate

---EndDate

---AbsenceType

But since i need to use an Adobe interactive form inside this view, the datasource for the form cannot be the root context node but some other node. So I replicated the same structure in the view context so as to make the fields visible in the Adobe form context. Now the context looks as below.

Context

---StartDate

---EndDate

---AbsenceType

---DATA_NODE

-----StartDate

-----EndDate

-----AbsenceType

Now my question is, how do i map the result from the Adobe form into the context of the view??

What code should i write and where should i write to achieve this?

I need to do the following. But dont know how to write the code for this.

Context.StartDate = Context.DATA_NODE.StartDate

Context.EndDate = Context.DATA_NODE.StartDate

Context.AbsenceType= Context.DATA_NODE.AbsenceType

Please help!

Any help will be greatly appreciated.

Thanks,

Sam

Accepted Solutions (1)

Accepted Solutions (1)

nikhil_bose
Active Contributor
0 Kudos

Context.StartDate = Context.DATA_NODE.StartDate

Context.EndDate = Context.DATA_NODE.StartDate

Context.AbsenceType= Context.DATA_NODE.AbsenceType


wdContext.currentContextElement().setStartDate (
    wdContext.currentDATA_NODE().getStartDate());

wdContext.currentContextElement().setEndDate(
    wdContext.currentDATANODE().getEndDate()); // if it start date use that

wdContext.currentContextElement().setAbsenceType(
  wdContext.currentData_NODE().getAbsenceType());

nikhiL

Former Member
0 Kudos

Thanks a lot Nikhil for the swift response.

My requirement was a bit more different. Here the mapping are not within the same context but 2 different contexts as below.

InterfaceControllerContext.StartDate = ViewContext.DATA_NODE.StartDate

InterfaceControllerContext.EndDate = ViewContext.DATA_NODE.StartDate

InterfaceControllerContext.AbsenceType= Context.DATA_NODE.AbsenceType

Please let me know how I can access the Interface Controller nodes and attributes from within the implementation of the view at the press of a submit button. I don't want to do this by binding.

Thanks again for your help!

Sam

nikhil_bose
Active Contributor
0 Kudos

Go to view controllers properties page, under Required Controllers click on add button and add controllers you want.

If you graphically mapped view-component-interface controllers the values would have reflected in all.

Added Hints: Please not the order of execution is view.wdDoinit(), componentController.wdDoInit() and last execution is interface controller's init().

nikhiL

Former Member
0 Kudos

Thanks Nikhil for the info. But I cant do a graphical mapping here because the view context has to have the data elements inside a node and the CC and IC have the data elements directly on the context and there is no node. So I can't do a graphical mapping. I have to map the values through code dynamically.

Former Member
0 Kudos

Thanks Nikhil, using your code and doing some alterations to it, i got this thing working. So awarded full points.

nikhil_bose
Active Contributor
0 Kudos

Former Member
0 Kudos

Hello Nikhil,

I'm stuck with another small issue.

Let me first explain what I'm trying to do.

I have a view with the context structure as follows

Context

---DATA_NODE (Node)

----


Data1

----


Data2

---Data1

---Data2

All i need to do is, at the start of the view, i need to move the data from

Context.Data1=>Context.DATA_NODE.Data1 and

Context.Data2=>Context.DATA_NODE.Data2

Also, at the View Submit button click, I need to move the data from

Context.DATA_NODE.Data1 => Context.Data1 and

Context.DATA_NODE.Data2 => Context.Data2

(I managed to do this submit button click by calling an action->method and wrote the code as you gave earlier)

wdContext.currentContextElement().setData1(wdContext.currentData_NodeElement().getData1());

wdContext.currentContextElement().setData2(wdContext.currentData_NodeElement().getData2());

But I wrote at wdInit() for the view the code in the reverse way, but the values are not getting passed to the Data_Node and hence its not defaulting with the values from the elements of the context.

This is what I wrote.

wdContext.currentData_NodeElement().setData1(wdContext.currentContextElement().getData1());

wdContext.currentData_NodeElement().setData2(wdContext.currentContextElement().getData2());

Please let me know if I'm doing something wrong here.

Appreciate your help in advance!

Cheers,

Sam

Former Member
0 Kudos

Also, if i hardcode the value in the Init() method of the view its working.

wdContext.currentData_NodeElement().setStartData1("Hi");

But its not working if i assign it through code like this.

wdContext.currentData_NodeElement().setData1(wdContext.currentContextElement().getData1());

Please help!

Thanks,

Sam

Edited by: Mandrake on May 1, 2008 7:13 PM

nikhil_bose
Active Contributor
0 Kudos

seems unusual.

Are you sure that you have data in wdContext.currentContextElement().getData1() ?

check whether you are invalidating the node values before they get assigned?

nikhiL

Former Member
0 Kudos

yeah. The value is there.

And what do you mean by invalidating the node??