on 02-16-2005 11:52 AM
I created two Views. One view, it was called NavigationView, contains all buttons.The other view, it was called PlanView, contains InputFields. I want to display the error message and highlighted the input field when the "Save" button is pressed and some of the input field is empty.
There is following code in method onActionSave() of NavigationView:
IWDNodeElement element = wdContext.currentContextElement().getElement();
String displayname = element.getAttributeAsText("name");
if (displayname == null || displayname.equals("")) {
IWDAttributeInfo attributeInfo = element.node().getNodeInfo().getAttribute("name");
this.messageManager.reportContextAttributeMessage(
element,
attributeInfo,
IMessageMaintenace.T_ENTER_NAME,
null,
false);
}
The attributes of element keep values of all input fields in the PlanView.
After executing this source code, the error message is displayed on the user interface in the Web browser but the input field that is linked with the invalid context attribute is no highlighted.
Is there any way to highlighted the input field?
Regards,
Krasimira
Hi Krasimira ,
To highlight a inputfield or any UIElement in a view you can do the following.
1. In the wdModifyView method first you need to create an intance of the UIElement.
Ex: input1=(InputField)view.getElement("inputfieldID");
(declare Input1 as a static global variable)
2.You can use the variable input1 in any action or method and type the following in that action/method.
input1.requestFocus();
The above call will place the control onto the respective
UIElement.
Regards,
Anilkumar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anilkumar,
> To highlight a inputfield or any UIElement in a view
> you can do the following.
>
> 1. In the wdModifyView method first you need to
> create an intance of the UIElement.
>
> Ex:
> input1=(InputField)view.getElement("inputfieldID");
>
> <b>(declare Input1 as a static global variable)</b>
Never ever do this! It simply doesn't work, if the view class is instantiated more than once (which is a rather probable scenario, i think). A static variable is shared between all instances of a class, so View-instance@1 might use the InputField-instance of View-instance@2! And, btw, the use of internal (not IWD/WD) classes (cast to InputField) is discouraged also.
> 2.You can use the variable input1 in any action or
> method and type the following in that action/method.
> input1.requestFocus();
Again no, simply forget it, it doesn't work.
Regards,
Stefan
This line looks strange to me,
IWDNodeElement element = wdContext.currentContextElement().getElement();
I can't access this method in sr1 dev studio. Are you sure you are getting the right element? Try wdContext.currentContextElement() if the attribute name is in the context node and just wdContext.currentBlahElement() if the attribute is in the blah node.
Highlighting the input fields works like a dream for us, but we use the raiseInvalidContextAttributeException method, accessing the message pool messages through wdComponentAPI.getTextAccessor().getText().
We also find webdynpro might be picky about capitalization, so if your attribute is named Name, it gives an exception
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Thomas,
IWDNodeElement element = wdContext.currentContextElement().getElement();
I have CustomController with attribute "element". In context of the PlanView and the NavigationView i have attributes with the same name "element". I map each of them to CustomController attribute "element".
The "element" is attribute of type IWDNodeElement.This node element contains attributes which values are displayed in input fields of the PlanView.
The attribute "name" is part of this IWDNodeElement "element" (one of input fields).
I check if the attribute "name" is not empty in the NavigationView. The message is displayed but the input filed is no highlighted.
If the button and input field are in one view - highlighting works but if the button and the input field are in different views it does not work.
Regards, Krasimira
I see what you are doing, but the approach doesn't seem right. The message manager is particular to your specific component. As far as I know, context attribute errors will not be propagated across different views, even if they are mapped correctly. In that sense, the msgmgr in navigationView and planView are two different objects.
So for your code, you could create an attribute called navigationViewMsgMgr and plantViewMsgMgr, reference the two, assign them the msgmgrs from API in wdDoInit and try calling the invalidAttribute exceptions on both.
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.