on 02-22-2008 6:55 AM
hai all,
I need to generate the checkbox dynamically at runtime based on user selections.I have gone thru the material provided by sdn.so plz dont provide those links and try to guide with the steps to be followed to create a checkbox dynamically.Its very urgent.
Thanks n Regards
Sharanya.R
Hi,
use
IWDTransparentContainer container; //your container
IWDCheckBox checkBox = (IWDCheckBox)view.createElement(IWDCheckBox.class);
//get the attribute of type boolean
IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("<Your Attribute>");
checkBox.bindChecked(attributeInfo);
container.addChild(checkBox);
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hai ayyaparaj,
thanks for the response.
but your coding when placed in wdodify view n on running gives the following error.
com.sap.tc.webdynpro.services.exceptions.WDRuntimeException: Property 'checked' of AbstractToggle with id '_1' in view 'Dynamicui' must be bound to the context
Thanks n Regards
Sharanya.R
Hi
following three lines are for this see you have aligned your code to the corresponding context attribute of yours.
//get the attribute of type boolean
IWDAttributeInfo attributeInfo = wdContext.getNodeInfo().getAttribute("<Your Attribute>");
checkBox.bindChecked(attributeInfo);
Regards,
Ayyapparaj
Thanks ayapparaj,
its working now but the text for checkbox should appear along with the checkbox.also iam going to generate the checkboxes based on user selection for that is it required to create the context at runtime or is it ok if the checkbox is binded to context created at designtime.
Thanks n Regards
Sharanya.R
Edited by: Sharanya R on Feb 22, 2008 8:40 AM
hai ayyaparaj,
Thanks its working.
I have a dropdown where the user selects a value.based on user selection the checkboxes shud be created in runtime.for eg.
if user chooses A in drop down
checkbox a-1,a2,a3 should be created dynamically.Should i create the context also at runtime for this or wat you suggested ll do for this.
Thanks n regards
Sharanya.R
Hi,
If the sccenario mentioned above is always fixed, what i mean by fixed is, the number of checkboxes created.
Then you can create the context and the UI element at design time and make the checkboxes visibility to NONE initially and later set it to visible.
If you are not aware of the number of checkboxes needed at design time, you can go for dynamic creation.
Regards
Ayyapparaj
Hi Saranya,
I think you better to use Checkboxgroup ratherthan check boxes.
Create a valuenode "DynCheck" under create attribute Value-"value".valuenode selection to "0..n"
Create Checkboxgroup ui element. create a attribute chkgrpVisible of type VISIBLE. bind it to the visible property of the Checkboxgroup.
bind "Dyncheck.value" to texts property.
in Onselect method of Dropdown by index use the below code:
Onselect(){
wdContext.nodeDynCheck().invalidate();
String select=wdContext.current<DropDown>Element().get<Value>();
// lets suppose getDynamicData returns you the array of checkbox names
String[] checkboxnames=getDynamicData(select);
if(checkboxnames.length>0)
wdContext.currentContextElement().setChkgrpVisible(WDVisibility.VISIBLE);
else
wdContext.currentContextElement().setChkgrpVisible(WDVisibility.NONE);
for(int i=0;i<checkboxnames.length;i++){
IprivateXXXview.IDynCheckElement ele=wdContext.createDynCheckElement();
ele.setValue(checkboxnames<i>);
wdContext.nodeDynCheck().addElement(ele);
}
}//onselect method end
to select checkboxes use
wdContext.nodenodeDynCheck().setSelected(index,true);
to unselect
wdContext.nodenodeDynCheck().setSelected(index,false);
hai,thanks the total number of checkboxes is 25 but the visibility is based on the user selection.The checkbox to be displayed is obtained from the db at runtime .in that case how can i bind the checkbox to existing context attribute .if i need to create context at runtime please help me in doin that.
Thanks n Regards
Sharanya.R
Hi,
Its better to create at runtime as the values in the backend table may vary.
To create a context attribute following is the code
IWDNodeInfo nodeInfo = wdContext.getNodeInfo();
// here a new attribute of type string is created
IWDAttributeInfo attributeInfo = nodeInfo.addAttribute("Count", "ddic:com.sap.dictionary.string");
Regards
Ayyapparaj
hai ayyaparaj,
when i create a context in runtime ll it be available in the context of my view after i run the application?
as i need to get the values of the dynamically created attributes and provide the next view based on thati need to know how the values can be set to the dynamically created attributes and how they can be used.please provide me with complete solution and solve the problem.
Thanks n regards
Sharanya.R
Edited by: Sharanya R on Feb 22, 2008 3:30 PM
Hi,
If you are creating the attributes in the view controller it will be available.
If your attribute is created in the controller then you need to map them to the view controller
wdContext.getNodeInfo().addMappedAttribute(name, mappedName)
To access the values of the attribute, their is no difference in accessing statically created and dynamically created.
wdContext.currentContextElement().getAttributeValue("<Your Dynamically created attributeName>")
Regards
Ayyapparaj
Hi,
I have created the dynamic checkbox.Its working fine.
I want to put onToggle click event for the check box.When click on the chickbox,I want to know whether I have selected or deselected the checkbox.I want to use this information in my wdDomodifyView().
All my UI elements are dynamic.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi Sharanya,
can u tell me the full step of dynamic programming of any Ui element from first step to last step.what should write in wdmodify() and wddoinit()?
plz tell me.its urgent.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
I think this is from the sdn but just an idea which would help you i think so .
As u want to create the form or the only check box Dynamically .
Firstly in wdDoInit() method we have to create a context node .
IWDNodeInfo node=wdContext.getNodeInfo().addChild("DynamicNode",null,true,true,false,false,false,true,null,null,null);
For creating the checkbox dynamically we will do the implementation in the W=wdDoModifyView() method .
we do this by the if else loop .
the condition for the first if is if(firstTime)
{
}
You call the container or Group yopu want the check box to be displayed .
for(int index = 0 ; index < theBackend.getNumberFields(); index++)
{ // Get Field MetaData
SomeBackEnd.FieldDescriptor fld=theBackend.getField(index);
IWDUIElement theUIElement=null;
IWDLabel theLabel=null;
// Create UI Elements :
// Create CheckBox
else if (fld.getUIType().equals("CheckBox"))
{
IWDCheckBox theCheckbox=(IWDCheckBox)view.createElement(IWDCheckBox.class,"inp"+index);
//Bind Value To Attribute Created In wdDoInit
theCheckbox.bindChecked("DynamicNode."+fld.getName());
theUIElement=theCheckbox;
}
then addd the element to the container
//Add UI Elements To The Container
theGroup.addChild(theLabel); theGroup.addChild(theUIElement);
I think this will help u .
Thanks & Regards
Anuradha Rao
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
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.