on 03-18-2009 1:30 PM
Hello,
I was trying make LOC_FROM and LOC_TO as required fields in VcTreMileageTable DC (package ess/tre/tre), but I didn't be successful.
I inserted this code in wdDoModifyView method:
IFieldControlNode nodeFieldControl =
(IFieldControlNode) wdThis.wdGetCustomizeController().getFieldControl();
for (int i = 0; i < nodeFieldControl.size(); i++)
{
IFieldControlElement element = nodeFieldControl.getFieldControlElementAt(i);
if (element.getFieldname().equals("LOC_FROM") || element.getFieldname().equals("LOC_TO"))
element.setRequired(true);
}
and in CustomController I had set:
startLocationField.setState(WDState.REQUIRED);
endLocationField.setState(WDState.REQUIRED);
but they didn't work.
If anyone have any input on this highly appreciated.
Thanks,
Damiano
Hi Damiano,
We have done this requirement recently. I have used the following code for making the two fields mandatory. Have a look and let me know if you have any other issues.
public void checkNoFirstDestination( java.lang.String Location )
{
//@@begin checkNoFirstDestination()
try{
IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
String value = wdContext.nodeGeneralData().currentGeneralDataElement().getLocation();
IWDAttributeInfo valueAttr = wdContext.nodeGeneralData().getNodeInfo().getAttribute(Location);
if(value.length()==0){
msgMan.reportContextAttributeMessage(wdContext.currentGeneralDataElement(), valueAttr,
IMessageVcTreGeneralData.NO_FIRST_DESTINATION , new Object[] {Location}, true);
}
}
catch(NullPointerException e){
IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
msgMan.reportMessage(IMessageVcTreGeneralData.REQUIRED_FIELDS, new Object[] {Location}, true);
}
//@@end
}
//@@begin javadoc:checkNoReasonForTrip()
/** Declared method. */
//@@end
public void checkNoReasonForTrip( java.lang.String Customer )
{
//@@begin checkNoReasonForTrip()
try{
IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
String value = wdContext.nodeGeneralData().currentGeneralDataElement().getCustomer();
IWDAttributeInfo valueAttr = wdContext.nodeGeneralData().getNodeInfo().getAttribute(Customer);
if(value.length()==0){
msgMan.reportContextAttributeMessage(wdContext.currentGeneralDataElement(), valueAttr,
IMessageVcTreGeneralData.NO_REASON_FOR_TRIP , new Object[] {Customer}, true);
}
}
catch(NullPointerException e){
IWDMessageManager msgMan = wdComponentAPI.getMessageManager();
msgMan.reportMessage(IMessageVcTreGeneralData.REQUIRED_FIELDS, new Object[] {Customer}, true);
}
//@@end
}
I hope this helps. Rewar d point s if helped...
Regards,
Gopal.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Damiano,
I tested your solution bat I have more rows with more locations... so I can not use your methods
If you do the Field validation for the fields in "VcTreGeneralData" DC, then it applies to all the rows as a general rule. I have had similar requirement and it is working for me.
I hope this helps. Let me know if you have any issues.
Regards,
Gopal.
Hi Damiano,
I have inserted the call to my method in the "onActionNextStep" method. Look at the following code. I hope this helps you.
public void onActionNextStep(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
{
//@@begin onActionNextStep(ServerEvent)
LOGGER.traceEnter("onActionNextStep");
wdThis.wdGetFcTraUtilsInterface().viewValidation(wdControllerAPI).validate(true);
this.checkNoFirstDestination("Location");
wdComponentAPI.getMessageManager().raisePendingException();
this.checkNoReasonForTrip("Customer");
wdComponentAPI.getMessageManager().raisePendingException();
wdComponentController.raiseFPMEvent(TravelConstants.EVENT_NAVIGATE_NEXT);
LOGGER.traceExit("onActionNextStep");
//@@end
}
Let me know if you have any issues.
Regards,
Gopal.
Hi Gopal,
If you do the Field validation for the fields in "VcTreGeneralData" DC, then it applies to all the rows as a general rule. I have had similar requirement and it is working for me.
This is true for LOC_TO field but in "VcTreGeneralData" DC I don't have the LOC_FROM field... so I can not set it as mandatory.
have you an other solution for my problem?
thanks
Damiano
Edited by: Damiano Callegari on Mar 19, 2009 9:44 AM
Hi Damiano,
I might not be able to give you the exact solution. But, I can advise you little bit.
Just write a logic for finding out the number of rows in the table by the time the user clicks on the "Accept Button" in the MileageDetails table and put an "IF" condition by enclosing my code within it. But, again it all depends on how you write your Logic. Sorry, I might not be able to help you anymore.
All the Best,
Gopal.
Hi
1.getFieldControl(); is this one method in CompCont which return type is integer?
2. and getFieldControl() also contain information about "LOC_FROM and LOC_TO what i mean is these are the field are processed in this method ?
provide the explanations
Best Regards
Satish Kumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
FieldControl is a node context of the Customize Custom Controller.
infact I had imported:
import com.sap.xss.tra.tre.vc.mileage.table.wdp.IPublicCustomize.IFieldControlElement;
import com.sap.xss.tra.tre.vc.mileage.table.wdp.IPublicCustomize.IFieldControlNode;
in TableView iView code.
so...
getFieldControl() returns the FieldControl node in Customize Custom Controller. I used nodeFieldControl as name of this variable.
This node contains more elements...
IFieldControlElement element = nodeFieldControl.getFieldControlElementAt(i);
A element contains more attributes. One of these is "Fieldname" that contain a string, also "LOC_FROM" and "LOC_TO".
LOC_FROM is the departure place, LOC_TO is the destination place.
I had processed it in wdDoModifyView because I would like these fields required in TableView iView.
Damiano
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.