on 02-06-2007 11:35 AM
Hi,
I have a Bapi which gives me the status of a inputfield (read only, edit, visible, obligitory). How can I make a field read only without that I need to make a value attribute for every field.
regards
Can you describe which UI elements you are using and how they are bound to the context?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
bapi Y_Tf_Isr_Getfield_Status:
- inputparameter
-- Scenario
- Output of bapi
-- Fein
-- fieldname
-- Fout
-- Fobl
-- Mandt
fill the data with
Y_tf_Get_Workitem_Info_Input
- output
-- fieldname
-- fieldvalue
-- fieldindex
Value node: PersonalData
- P0002_VORN
- P0002_NACHN
- P0002_GBORT
etc
these are binded to the inputfield
to fill the data is:
try
{
Y_Tf_Get_Workitem_Info_Input inputWGI = new Y_Tf_Get_Workitem_Info_Input();
if(strParameter.equals("view1"))
{
IPrivateUWL_Form_Cust.IPersonalDataElement field =
wdContext.createPersonalDataElement();
inputWGI.setWorkitem_Id(WDWebContextAdapter.getWebContextAdapter().getRequestParameter("wi_id"));
inputWGI.execute();
Iterator it = inputWGI.getResult().iterator();
while (it.hasNext()) {
Y_Tf_Get_Workitem_Info_Output output =
(Y_Tf_Get_Workitem_Info_Output) it.next();
Iterator records = output.getSpecial_Data().iterator();
while (records.hasNext()) {
Object obj = records.next();
System.out.println(obj);
Qisrsspecial_Param record =
(Qisrsspecial_Param) obj;
String fieldname = record.getFieldname();
String fieldvalue = record.getFieldvalue();
try {
Method method =
field.getClass().getMethod(
"set" + fieldname,
new Class[] { String.class });
method.invoke(field, new Object[] );
} catch (SecurityException e) {
logger.catching(e);
} catch (IllegalArgumentException e) {
logger.catching(e);
} catch (NoSuchMethodException e) {
logger.catching(e);
} catch (IllegalAccessException e) {
logger.catching(e);
} catch (InvocationTargetException e) {
logger.catching(e);
}
}
}
this.wdContext.nodePersonalData().bind(field);
} // end if statement view 1
} // end of TRY statement
catch (Exception e) {
wdComponentAPI.getMessageManager().reportException(e.toString(), false);
}
If you do not want to use value attributtes you need to set the "readonly" property in the wdDoModifyView.
For an IWDInputField named test to set to readonly, this would be as simple as:
test.setReadOnly(true);
Note that by using this in the wdDoModifyView your entire UI tree will be rendered again. If you use value attributes this is not the case (so performs better).
Johan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Like this:
public static void wdDoModifyView(IPrivateTestView wdThis, IPrivateTestView.IContextNode wdContext, com.sap.tc.webdynpro.progmodel.api.IWDView view, boolean firstTime)
{
//@@begin wdDoModifyView
IWDInputField test = (IWDInputField)view.getElement("test");
test.setReadOnly(true);
//@@end
}
Johan
the code I am having, note: bapi dups me a table. how should it look like then.
if (firstTime)
{
for(int i = 0; i < wdContext.nodeYtf_Isrfield_Def().size(); i++)
{
wdContext.nodeYtf_Isrfield_Def().moveTo(i);
String fieldName = wdContext.currentYtf_Isrfield_DefElement().getFieldname();
if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFobl().equals("X"))
{
wdThis.wdGetContext().currentPersonalDataElement().setAttributeValue(""+fieldName, WDState.REQUIRED);
}
else if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFobl().equals(""))
{
wdThis.wdGetContext().currentPersonalDataElement().setAttributeValue(""+fieldName, WDState.NORMAL);
}
else if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFein().equals("X"))
{
IWDInputField readonly = (IWDInputField)view.getElement("Inputfield");
readonly.setReadOnly(false);
}
}
}
Hi Eoin,
This depends on the naming of your inputfields. If you name the fields after the BAPI fieldnames, you can use the same iteration as you are using for the wdstate.
for(int i = 0; i < wdContext.nodeYtf_Isrfield_Def().size(); i++)
{
wdContext.nodeYtf_Isrfield_Def().moveTo(i);
String fieldName = wdContext.currentYtf_Isrfield_DefElement().getFieldname();
if (wdThis.wdGetUWL_Form_CustController().wdGetContext().currentYtf_Isrfield_DefElement().getFein().equals("X")) {
IWDInputField inputfield = (IWDInputField)view.getElement(fieldName);
inputfield.setReadOnly(false);
}}
Johan
BTW, why are you using context attributes for the wdstate, but not for the readonly property?
BTW2, you shouldn't place the other code (in which you alter context element) in the wdDoModifyView method, but (for instance) in the wdDoInit method.
hi,
Declare a value attribute as boolean and bind to readonly option of your value attribute.
And write the code based on your requirement where ever do u need readonly.
wdContext.currentcontextElement().set<BooleanAttribute>(false);
Thanks,
Lohi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
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.