on 02-25-2008 5:11 AM
hai all,
i have created the checkboxes at runtime but they are getting displayed in the same line.
i need to display them one after the other in next lines.please help me its urgent.
Thanks n Regards
Sharanya.R
Hi,
create a container and set the layout as rowlayout.
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
To solve the problem, I have created one Java class
public class UIHandler {
/*
Call this method to create node in Component controller as the data should be shared among
multiple views
@param rootInfo is NodeInfo for wdContext in Component Controller
@param name of Value node to be created
@param Collection represents the list of attributes to be created for check boxes
*/
public static IWDNodeInfo createChildNode(
IWDNodeInfo rootInfo,
String name,
Collection collection) {
IWDNodeInfo node =
rootInfo.addChild(
name,
null,
true,
true,
false,
true,
false,
true,
null,
null,
null);
for (Iterator iter = collection.iterator(); iter.hasNext();) {
String str = (String) iter.next();
node.addAttribute(str, "com.sap.dictionary.boolean");
}
return node;
}
/*
Call this method to create node in view to create list of check boxes
*/
public static IWDNodeInfo createMappedChildNode(
IWDNodeInfo nodeInfoOrigin,
IWDNodeInfo rootInfo,
String name) {
IWDNodeInfo nodeInfoView =
rootInfo.addMappedChild(
name,
null,
nodeInfoOrigin.isSingleton(),
nodeInfoOrigin.isMandatorySelection(),
nodeInfoOrigin.isMultiple(),
nodeInfoOrigin.getPathDescription(),
false,
true);
for (Iterator iter = nodeInfoOrigin.iterateAttributes();
iter.hasNext();
) {
IWDAttributeInfo attrInfo = (IWDAttributeInfo) iter.next();
nodeInfoView.addMappedAttribute(
attrInfo.getName(),
attrInfo.getName());
}
return nodeInfoView;
}
/*
Create list of check boxes
*/
public static void createCheckBoxes(
IWDView view,
String rootContainerName,
IWDNodeInfo nodeInfo) {
IWDTransparentContainer rootCont =
(IWDTransparentContainer) view.getElement(rootContainerName);
IWDTransparentContainer cont =
(IWDTransparentContainer) view.createElement(
IWDTransparentContainer.class,
"Container");
IWDGridLayout layout =
(IWDGridLayout) cont.createLayout(IWDGridLayout.class);
layout.setColCount(2);
rootCont.addChild(cont);
for (Iterator iter = nodeInfo.iterateAttributes(); iter.hasNext();) {
IWDAttributeInfo attrInfo = (IWDAttributeInfo) iter.next();
IWDLabel label =
(IWDLabel) view.createElement(
IWDLabel.class,
attrInfo.getName());
label.setText(attrInfo.getName());
IWDCheckBox cbx =
(IWDCheckBox) view.createElement(
IWDCheckBox.class,
attrInfo.getName() + "cbx");
cbx.bindChecked(attrInfo);
label.setLabelFor(cbx.getId());
cont.addChild(label);
cont.addChild(cbx);
}
}
}
Now, to create context node in component controller, use following code,
List list = new ArrayList();
list.add("Label of check box");
............... .........................
IWDNodeInfo nodeInfo = UIHandler.createChildNode(wdThis.wdGetTestController().wdGetContext().getNodeInfo(), "Data", list);
UIHandler.createMappedChildNode(nodeInfo, wdContext.getNodeInfo(), "Data");
To create check box, use following code in wdModifyView,
if(firstTime) {
IWDNode node = wdContext.getChildNode("Data", 0);
IWDNodeInfo nodeInfo = node.getNodeInfo();
UIHandler.createCheckBoxes(view, "RootUIElementContainer", nodeInfo);
}
And to access the values of the check boxes in different view, put the following code in wdInit()
IWDNodeInfo nodeInfo = wdThis.wdGetTestController().wdGetContext().getChildNode("Data", 0).getNodeInfo();
UIHandler.createMappedChildNode(nodeInfo, wdContext.getNodeInfo(), "Data");
And in wdModifyView
if(firstTime) {
IWDNode node = wdContext.getChildNode("Data", 0);
IWDNodeInfo nodeInfo = node.getNodeInfo();
UIHandler.createCheckBoxes(view, "RootUIElementContainer", nodeInfo);
}
Thanks,
Puspendu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Any reason why you don't use a CheckBoxGroup?
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That was my guess. Using a CheckBoxGroup is much simpler here because you don't need to create the context structure programmatically but only the context data.
Example: Create a context node "Items" (cardinality=0:n, selection=0:n) with an attribute "text" (string) at designtime. Bind the CheckBoxGroup.texts property to the attribute "text".
At runtime, add elements to the "Items" node:
for (int i = 0; i < 3; ++i)
{
IItemsElement e = wdContext.nodeItems().createItemsElement();
wdContext.nodeItems().addElement(e);
e.setText("Item #" + i);
}
This will give you a check box group with all boxes unchecked. To check the box at index i, you need to set the selection of the node at index i:
wdContext.nodeItems().setSelected(i, true);
To have each check box in a new line, set "colCount" = 1 for the check box group.
That's it.
Armin
Hi Sharanya,
For displaying 25 items in a check box Grp; first create a simple type and in its Enumeration tab give all the 25 values that you want. Assign this to the Context element and bind it with the CheckBox Grp.
This will work;
For your layout; use the Grid layout that positions UI elements( Check Boxes) one by one. (One more Option; use property "Column count" that also will help you in time)
Regards
- Vinod
*Reward me, if it helps you.
need more info
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Change the layout of the group(or what ever container) to which you are adding to Gridlayout.
Regards,
Sudhir
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 | |
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.