on 11-28-2007 11:34 AM
I've got some elements in my view layout that have their readOnly property linked to a context element.
Now, in the wdDoModifyView method, I want to set some elements readOnly property to true.
((IWDAbstractInputField) uiEl).setReadOnly(true)
However, this gives problems for those elements whose readOnly property is linked with a context element.
java.lang.NullPointerException
at com.sap.tc.webdynpro.clientserver.data.DataContainer.removePendingUserInput(DataContainer.java:1231)
at com.sap.tc.webdynpro.clientserver.data.DataContainer.setBoolean(DataContainer.java:891)
at com.sap.tc.webdynpro.clientserver.uielib.standard.impl.AbstractInputField.setReadOnly(AbstractInputField.java:724)
at com.carrefour.be.evere.msstime.uiinput.UIInputInterface.disableUIElement(UIInputInterface.java:146)
at com.carrefour.be.evere.msstime.uiinput.UIInputInterface.disableUIElement(UIInputInterface.java:139)
at com.carrefour.be.evere.msstime.uiinput.UIInputInterface.disableUIElement(UIInputInterface.java:130)
Why do you do this inside wdDoModifyView() at all? Just set the value of the context attribute to which the "readOnly" property is bound in the event handler.
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok, I think I understand what you are trying to do.
The error is caused by an attempt to store a boolean value in a non-existing context attribute. This may happen for example, if the attribute is part of a non-singleton node without parent element.
I'm not sure if this is a bug in your release but in any case a better exception than a NPE should be thrown.
Armin
These views, that are switched to read-only by the generic code, belong to certain Web Dynpro components.
Wouldn't it be possible to define the needed context bindings in these views and just offer a method on their component interface to set the read-only state? Then you would not have to traverse views generically, you would just have to call one method.
Or are these views from completely "foreign" Web Dynpro components?
Armin
Lakshmi,
public void disableUIElement(com.sap.tc.webdynpro.progmodel.api.IWDUIElement uiEl ) {
//@@begin disableUIElement()
if (uiEl instanceof IWDUIElementContainer) {
IWDUIElement[] elements = ((IWDUIElementContainer) uiEl).getChildren();
List l = Arrays.asList(elements);
Iterator i = l.iterator();
while (i.hasNext()) {
disableUIElement((IWDUIElement) i.next());
}
}
else if (uiEl instanceof IWDTable) {
IWDTableColumn[] cols = ((IWDTable) uiEl).getColumns();
List l = Arrays.asList(cols);
Iterator i = l.iterator();
while (i.hasNext()) {
IWDTableColumn tc = (IWDTableColumn) i.next();
disableUIElement((IWDUIElement) tc.getTableCellEditor());
}
}
else if (uiEl instanceof IWDAbstractDropDown) {
((IWDAbstractDropDown) uiEl).setEnabled(false);
}
else if (uiEl instanceof IWDAbstractInputField) {
((IWDAbstractInputField) uiEl).setReadOnly(true);
}
else if (uiEl instanceof IWDAbstractButton) {
((IWDAbstractButton) uiEl).setEnabled(false);
}
//@@end
}
public static void wdDoModifyView(...) {
wdThis.wdGetUIInputInterface().disableUIElement((IWDUIElement view.getRootElement());
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
Check the id of the inputField which you are passing while creating the instance of IWDAbstractInputField. Else use the following:
IWDAbstractInputField inp = (IWDAbstractInputField) viewObj.getElement("InputField");
inp.setReadOnly(true);
thanks & regards,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Can u send me complete code..
Try using IWDInputFiled inplace of IWDAbstractInputFiled
Regards
LakshmiNarayana
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
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.