on 05-04-2006 3:25 AM
I have a view that is bound to a Web Service.
The model contains one customer name etc. and many equipment lines .
The equipment lines are represented by an array of object type EquipmentLine in the Web Service.
The equipment lines are displayed in table form in the View.
I create the elements for the table at run time so that the fields within the
EquipmentLine may be entered (these are code and quantity).
This works fine and on submission the context is passed to the controller OK.
Just before the Web service call I take a look at the component controller context to make sure all is ok:
String eCode = "";
String qty = "";
for (int i = 0; i < n; ++i) {
IEquipmentLineItemsElement item =
wdContext
.nodeEquipmentLineItems()
.getEquipmentLineItemsElementAt(i);
eCode = item.getEquipmentCode();
qty = item.getQuantity();
}
everything looks fine at this point.
then I call the Web Service:
wdContext.currentMakeDispatchElement().modelObject().execute();
Everthing is passed to the Web Service apart from the EquipmentLine details.
Here's a snippet from the SOAP created:
<ns1:makeDispatch xmlns:ns1='http://ws.xxxx.com.xxu'>
<equipmentMovementRequest xsi:type='tns:EquipmentMovement' xmlns:tns='urn:ChepWeb'>
<dispatchCust xsi:type='xs:string'>99999999</dispatchCust>
<dispatchDate xsi:type='xs:string'>04/05/06</dispatchDate>
<equipmentLineItems xsi:nil='true'></equipmentLineItems>
<sendReference xsi:type='xs:string'>test reference</sendReference>
</equipmentMovementRequest>
Note that the equipmentLineItems is null.
What do I need to do to get EquipmentLineItems from the context into the Web Service?
Nigel.
Hi Nigel,
Just make sure that you have relation between MakeDispatch and EquipmentLine model nodes: select EquipmentLine, go to properties, check property "Model.supplyingRelationRole". If it is empty - select available one from drop down list.
Best regards, Maksim Rashchynski.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
> Hi Nigel,
>
> Just make sure that you have relation between
> MakeDispatch and EquipmentLine model nodes: select
> EquipmentLine, go to properties, check property
> "Model.supplyingRelationRole". If it is empty -
> select available one from drop down list.
>
> Best regards, Maksim Rashchynski.
Hi Maksim ,
the relationship goes MakeDispatch -> equipmentMovementRequest -> equipmentLineItems.
The Model.supplyingRelationRole for node is already equipmentLineItems.
The Model.supplyingRelationRole for equipmentMovementRequest is already equipmentMovementRequest.
Any other ideas?
Nigel
Hi Valery,
I populate the table thus in the component controller:
for (int i = 0; i < 5; i++) {
equipLine = new ComplexType_EquipmentLineItem();
equipLine.setEquipmentCode("");
equipLine.setQuantity("");
lineElement =
wdContext
.nodeEquipmentLineItems()
.createEquipmentLineItemsElement(
equipLine);
wdContext.nodeEquipmentLineItems().addElement(lineElement);
}
Data is then entered into the table by the user.
Then just before the web service is invoked I examine the value
of the table in the component controller :
int n = wdContext.nodeEquipmentLineItems().size();
String eCode = "";
String qty = "";
String dummyCode = "";
ComplexType_EquipmentLineItem equipLine = null;
//testing purposes only to view user enetered data
for (int i = 0; i < n; ++i) {
IEquipmentLineItemsElement item =
wdContext
.nodeEquipmentLineItems()
.getEquipmentLineItemsElementAt(
i);
eCode = item.getEquipmentCode();
qty = item.getQuantity();
}
// end testing
// now call the web service
try {
wdContext.currentMakeDispatchElement().modelObject().execute();
wdContext.nodeResponse().invalidate();
wdContext.nodeResult().invalidate();
} catch (Exception ce) {
manager.reportException(ce.getMessage(), false);
}
so as you can see I dont actually do anything with the data myself as
it should be mapped to the web service.
All the other fields (non table) go through to the web services OK.
Do I have to do something explicit to get this table data into the web service?
Nigel
Hi Nigel,
Try this code for initialization
MakeDispatch makeDispatch = new MakeDispatch();
for (int i = 0; i < 5; i++) {
equipLine = new ComplexType_EquipmentLineItem();
equipLine.setEquipmentCode("");
equipLine.setQuantity("");
makeDispatch.addEquipmentLineItems(equipLine);//NOT EXACTLY THE SAME METHOD BUT SOMETHING SIMILAR
}
wdContext.nodeMakeDispatch().bind(makeDispatch);
Best regards, Maksim Rashchynski.
Hi again Maksim,
Sorry for my brevity in my last reply.
Let me try explain a bit more clearly...
The context is as follows:
Context root has value node MakeDispatch.
MakeDispatch has value node equipmentMovementRequest.
equipmentMovementRequest has value node equipmentLineItems.
equipmentMovementRequest has value attributes dispatchCust and dispatchDate
equipmentLineItems has value attributes equipmentCode and quantity.
The nearest I can get to the code you suggest is:
ComplexType_EquipmentMovement em = new ComplexType_EquipmentMovement();
for (int i = 0; i < 5; i++) {
equipLine = new ComplexType_EquipmentLineItem();
equipLine.setEquipmentCode("");
equipLine.setQuantity("");
em.addEquipmentLineItems(equipLine);//NOT EXACTLY THE SAME METHOD BUT SOMETHING SIMILAR
}
wdContext.nodeEquipmentMovementRequest().bind(em);
But then I dont even get the details of dispatchCust and dispatchDate passed to the Web Service.
Nigel
Hi Nigel,
What about something like this:
final MakeDispatch makeDispatch = new MakeDispatch();
final ComplexType_EquipmentMovement em = new ComplexType_EquipmentMovement();
makeDispatch.set(or add?)equipmentMovementRequest(em);
ev.setDispatchCust("Cust");
ev.dispatchDate(new Date());
for (int i = 0; i < 5; i++) {
equipLine = new ComplexType_EquipmentLineItem();
equipLine.setEquipmentCode("");
equipLine.setQuantity("");
em.addEquipmentLineItems(equipLine);
}
wdContext.nodeMakeDispatch().bind(makeDispatch);
Best regards, Maksim Rashchynski.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.