on 03-09-2007 7:46 AM
I want to add Input fields and labels in the a group in a view on click of a button.
How to :
1)Access the right gropu in view through code?
2)Create elements in the group through code?
Please reply soon!
Sumit
Hi All,
I also want to change the layoutdata of a UI element through code.
Please help!
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Armin,
Please can you tell me :
How to bind the view contexts with a model context through code?
Reply soon!
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Armin ,
That problem got solved.
I have defined a simple type and used it.
Thanks!
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Armin,
Your code actually suits my situation and I am adding a row on click of the button
(Row contains Inputfields and labels)
When i have to create value attribute I need to give data type in addAttribute() function .
In layout for the first row I have choosen string as the data type.
While going with coding when i give the data type String or char or long.
It gives an exception.
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Armin,
Thanks for your answer.
I have given String type for the first row.
But while creating a new context attribute through code I a unable to give the String data type.
What should I do?
Sumit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need a flag to signal that the elements should be added with the next call to wdDoModifyView().
Add a boolean context attribute "AddFields" to the view context and set it to true in the action handler for the button:
void onActionAddFields(...)
{
wdContext.currentContextElement().setAddFields(true);
}
In method wdDoModifyView(), check the flag and reset it after the code that adds the fields:
(I assume the group has a MatrixLayout)
static void wdDoModifyView(...)
{
if (wdContext.currentContextElement().getAddFields())
{
/* access group by ID given at designtime */
IWDGroup group = (IWDGroup) view.getElement("groupID");
IWDLabel label = (IWDLabel) view.createElement(IWDLabel.class, null);
/* if new row in MatrixLayout should be started: */
IWDMatrixHeadData labelLayoutData = label.createLayoutData(IWDMatrixHeadData.class);
/* change settings for layout data if needed */
label.setText("whatever");
IWDInputField field = (IWDInputField) view.createElement(IWDInputField.class, null);
/* if in same row as label: */
IWDMatrixData fieldLayoutData = field.createLayoutData(IWDMatrixData.class);
/* change field layout data if needed */
field.bindValue("context.attribute.path");
label.setLabelFor(field);
group.addChild(label);
group.addChild(field);
wdContext.currentContextElement().setAddFields(false);
}
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
In your WdModifyView add this code simply.
// Root element of the every view capture the initially.
IWDTransparentContainer container = (IWDTransparentContainer)view.getElement(IWDTransparentContainer.class,"RootUielementcontainer");
// create the Group dynamically.
IWDGroup theGroup = (IWDGroup)view.getElement("InputGroup");
// create your ui elements add to be group.
IWDButton but = (IWDButton)view.createElement(IWDButton.class,"but");
but.setText("rama");
but.setTooltip("Developpment");
// create on more lablel
IWDLabel label = (IWDLabel)view.createElement(IWDLabel.class,"nagu");
label.setText("rama");
// finally add your label and button to Group.
grp.addChild(but);
grp.addChild(label);
// group to be added to container.
container.addChild(grp);
This might helps you.
Thanks,
Lohi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
1. You always know the id of the Group UI element from the designtime. So in the wdDoModifyview() method, you will need to do
view.getElement("id_of_group");
2. For this go through <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/4f/07cf3dd28b5610e10000000a114084/frameset.htm">this</a> link.
Regards,
Satyajit.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sumit
in wdModifyView() write the code accordingly
IWDButton theButton = (IWDButton)view.createElement(
IWDButton.class, "butn");
IWDGroup theGroup = (IWDGroup)view.getElement("Group1");
theGroup.addChild( theButton);
this code adds button to your group with id "Group1".
for more information on dynamic UI Elements go through this link
Regards
Abhimanyu L
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
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.