on 01-18-2007 6:49 AM
Hi,
I have requirement like , a view cotaining lables and input fields and one combo box.Based on the cotent selection in combo box some lables and input fields should be hide.In html it is possible by using javascript .So how i will do in web dynpro.
Thanks & Regards
muna
Hi Muna,
Each UI Element has a 'visible' property.
Define a new context attribute of type com.sap.ide.webdynpro.uielementdefinitions.Visibility.
Bind the new context attribute to the visibile property of the UIElement you want to display or not display.
In the code when you want the UIElement to be displayed add the line:
wdContext.currentContextElement().setUIVisibility(WDVisibility.VISIBLE);
When you want the UIElement not to be displayed:
wdContext.currentContextElement().setUIVisibility(WDVisibility.NONE);
Regards, Adi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Probably you don't want to show or hide individual UI elements, but rather groups or at least label/field pairs.
So you could create for each such logical group G a context attribute "GVisibility" of DDIC type Visibility (as already explained by the other posters).
Next, bind the "visible" property of each UI element that belongs to G to attribute "GVisibility".
Now you have two possibilities to evaluate these attributes:
Either
- assign an action to the "onSelect" event of the drop-down list and evaluate and set the attribute values in the action handler, or
- define all attributes as calculated and write the code in the get-method of the calculated attribute.
The first possibility will be more efficient.
Code sketch:
Context:
- Entries (node, card=0:N, selection=0:1)
+ -- Value (attribute, type=string)
+ -- Text (attribute, type=string)
- GVisibility (attribute, type=Visibility)
UI elements:
EntryList: DropDownByIndex
Label: Label
Field: InputField
Binding:
EntryList.texts = Entries.Text
EntryList.onSelect = EntrySelected
Label.visible = GVisibility
Field.visible = GVisibility
Action handler:
onEntrySelected()
{
IEntriesElement selectedEntry = wdContext.nodeEntries().currentEntriesElement();
if ( selectedEntry == null )
{
/* nothing selected, make elements of group G invisible */
wdContext.currentContextElement().setGVisibility(WDVisibility.NONE);
}
else if ( "some_value".equals(selectedEntry.getValue()) )
{
/* make elements of group G visible */
wdContext.currentContextElement().setGVisibility(WDVisibility.VISIBLE);
}
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Muna,
If you want your lables/input fields to be displayed or hidden you need to create a context attribute of type : com.sap.ide.webdynpro.uielementdefinitions.Visibility.
Create context attribute then go to properties -> select the type as vIsibility(Go to Local Dictionlary -> select tha package "com.sap.ide.webdynpro.uielementdefinitions" -> select the type as Visibility -> Ok )
Now go to properties of Label/Input Filed and set the visible property to the context attribute you have created.
Finally depending on the condition you can set the Visible property:
if(cond)
wdContext.currentContextElement().set<contextAttribute>(WDVisibility.NONE);
else
wdContext.currentContextElement().set<contextAttribute>(WDVisibility.VISIBLE);
This solves your problem.
Regards,
Jhansi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
25 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.