on 07-25-2005 12:32 PM
hi dear wd experts,
i have created a 2 coloumns table, which retrieves data from a model object. It's context is nodeUTablenodeUrowsattribute1.
the second table column contains a checkbox.
For the checkbox I set up a node, which carries a bool variable and which is assigned to the checkbox "checked" poperty.
I set the cardinality of the checkbox node 1:n (when using 0:n the checkboxes are disabled...)
During wdDoModify I create checkbox contexts like this:
wdContext.nodeStandard().invalidate();
int rsize = wdContext.nodeUrows().size();
for (int i = rsize - 1; i >= 0; i--)
{
IPrivateDealer.IStandardElement standard =
wdContext.createStandardElement();
wdContext.nodeStandard().addElement(standard);
}
so I get as many bool vars as required. I am not sure about the "invalidate()" method.
I thought, when using it like above, I could also use a 0:n cardinality for my checkbox contents. But even "validate()" won't enable the checkboxes on the webpage... hence I use 1:n.
Now I set up an onToggle Event for the checkbox, which looks like this:
if(wdContext.currentStandardElement().getBolStandard()==false){
wdContext.currentStandardElement().setBolStandard(true);
}else{
wdContext.currentStandardElement().setBolStandard(false);
}
Unfortunatly this only works for all checkboxes, and furthermore, once checked, I can't reset the checkboxes.
I also tried to use the getLeadSelection() of my nodeUrows. But this returns always 1.
<b>Big Question goes here:
How can I address only one checkbox???</b>
thanx a lot for your patience and help...
Matthias
Let "Rows" be the context node used as the table's data source, cardinality(Rows) = 0:N, and let "B" be a boolean attribute in "Rows".
Let "cb" be the (CheckBox) table cell editor for the second column. Bind the "cb.checked" property to attribute "B".
Fill node "Rows" with node elements to get table rows.
Then the check box in row i is checked if the node element Rows(i).B = true.
In an action handler for the "CheckBox.onToggle" event, you can get the new checked state either from the node element or the event parameter "checked".
To map the event parameter "checked" to a parameter "newCheckedState" in the action handler, define an event parameter mapping in method wdDoModifyView():
if (firstTime)
{
IWDCheckBox cb = (IWDCheckBox) view.getElement("cb");
cb.mappingOfOnToggle().addSourceMapping("checked", "newCheckedState");
}
Armin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi armin et al,
thanx for all the messages - i followed different different approaches. Armins for instance.
So I put a boolean var in in my modelnode which "Rows" and bound it to the checked property of the celleditor checkbox. The bool var is called "bolStandard" in my case.
Now in the "CheckBox.onToggle" event, I declared:
if(wdContext.currentUrowsElement().getBolStandard()==false){
wdContext.currentUrowsElement().setBolStandard(true);
}else{
wdContext.currentUrowsElement().setBolStandard(false);
}
The point is, the checkbox won't check, and the leadselection of the table jumps back to the first row.
What went wrong?
I did not set up any parameters for the event, like somebody here suggested...
I also did the wdDoModify like this (in firstTime):
// checkboxen
IWDCheckBox cb = (IWDCheckBox) view.getElement("cb");
cb.mappingOfOnToggle().addSourceMapping("checked", "newCheckedState");
thanx once more - points will be rewarded of course to every single helpful feedback,
matthias
Hi Armin,
oops, i just did not know, taht i don't have to toggle the value - i did it with checkbox, which stand alone and get the state that way. Anyway - i killed the toggle event, and the checkboxes behave fine.
Now I don't get the state...
in my doModify I entered
// checkboxen
IWDCheckBox cb = (IWDCheckBox) view.getElement("cb");
cb.mappingOfOnToggle().addSourceMapping("checked", "newCheckedState");
if(cb.getChecked()==true){
wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("10");
}else{
wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning("20");
}
I always see a "20" which means state is false...
if you finally tell me how to grap the actual value (true/false) i shall deliver 10 points...
thanks once more,
matthias
ps: I also created an if/else branch for if(firstTime){}else{}
Message was edited by: matthias kasig
Hi,
You must have created an action for onToggle .
For that create a parameter newCheckedState of type boolean (the name as mentioned in ur code..)
<b> cb.mappingOfOnToggle().addSourceMapping("checked", "newCheckedState");</b>
Now inside that action handler you can get the current chk box state from the argument "newCheckedState"
Regards
Bharathwaj
hi Bharathwaj,
ok, i can actually get the value, but now the checkbox does not remain checked, when applying the onToggle Event:
my onToggle looks like this:
public void onActionsetStandard(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent, boolean newCheckedState )
{
//@@begin onActionsetStandard(ServerEvent)
if (newCheckedState==true){
wdComponentAPI.getComponent().getMessageManager().
reportWarning(newCheckedState+" my value of checkbox");
}
//@@end
so how do i manage to leave the checkbox checked?
also the leadSelection jumps back to the first row.
thanx,
matthias
Message was edited by: matthias kasig
I already told how to get the new checked value in the action handler:
Declare an action parameter "newCheckedState" in the action that is bound to the "onToggle" event and put the parameter mapping code from my previous post into wdDoModifyView(), nothing else.
Then the action handler parameter will contain the new checked value after the checkbox has been toggled.
Armin
Hi.
<b>wdContext.nodeStandard().invalidate();
int rsize = wdContext.nodeUrows().size();
for (int i = rsize - 1; i >= 0; i--)
{
IPrivateDealer.IStandardElement standard =
wdContext.createStandardElement();
wdContext.nodeStandard().addElement(standard);
}</b>
As per this code ur invalidating in wdDoModifyView.. Are u still having that line.
Dont invalidate the node which has the value of chkbox state.
Otherwise you dont have to do anything else.
The value will remain,...
No ifs and else s neeeded
Regards
Bharathwaj
Armin,
in my wdDomodify in firstTime I have:
// checkboxen
IWDCheckBox cb = (IWDCheckBox) view.getElement("cb");
cb.mappingOfOnToggle().addSourceMapping("checked", "newCheckedState");
I also have an action with paramter "newCheckedState" as boolean.
I can also see newCheckedState:
here coding from my actionhandler:
if (newCheckedState==true){
wdComponentAPI.getComponent().getMessageManager().
reportWarning(newCheckedState+" bolStd");
}
The point is like described in my post above, that the leadselection jumps back, and the cb does not keep the state "checked" - the little mark disappears straight away...
matthias
Bharathwaj,
I deleted this section already, and followed Armin. So right now, I have a boolean var within my Urows context, which delivers data for the tableview.
I am not invalidating anymore.
the point is, the value gets in my actionhandler method, which i set up like u said, with a bool parameter newCheckedState.
<b>It's only that the checkbox <i>unchecks</i>.</b>
😐
matthias
Please post your exact context structure.
In your first post, you wrote that you created an extra node:
<i>
For the checkbox I set up a node, which carries a bool variable and which is assigned to the checkbox "checked" poperty.
I set the cardinality of the checkbox node 1:n (when using 0:n the checkboxes are disabled...)</i>
You should either add the boolean attribute directly under the table's data source node or, if you cannot add it there (because it's a model node), add a value node (cardinality 1:1, selection 1:1) with the boolean attribute in it.
Armin
Armin,
better forget about my entry post.
i tried lots of different things.
right now i have a value node, under my model node, with cardinality 1:1 and selection 0:1 and singleton set to false (otherwise i get runtime errors).
When I use a value node outside the Urows (model)node, i get all boxes checked when hitting one. But at least they remain checked.
and as i said right before, i can obtain a changed value in the evHandler, but the checkbox "unchecks" (I mean, when watching in the Internet Explorer).
<b>and I do not invalidate() anymore!</b>
so this is still a problem,
matthias
Message was edited by: matthias kasig
hi,
armin, do u think maybe the supply function which is being introduced in a blog "Supply functions in WebDynpro"
by Marcin Galczynski can help in my case?
I set up my whole concept like Marcin does in hie blog (so I have a value node 1:1 cardinality, 0:1 selection singleton fasle, under a model node.
The supply function goes like this:
public void supplyBol(IPrivateDealer.IBolNode node, IPrivateDealer.IUrowsElement parentElement)
{
//@@begin supplyBol(IWDNode,IWDNodeElement)
IPrivateDealer.IBolElement mybol = node.createBolElement();
node.bind(mybol);
mybol.setBolStandard(<b>true</b>);
//@@end
}
there where I have the mybol.setBolStandard(<b>true</b>);
should be something like the actual selected checkboxstate.
I tried <i>mybol.setBolStandard(wdContext.currentBolElement().getBolStandard());</i>
but still the checkboxes uncheck, otherwise if i put in true, they are all checked...
matthias
Yes, do it like described in that Weblog.
Because "Rows" is a model node, you cannot directly add the boolean attribute "B" which would make things simpler.
Instead add a value node "V" (cardinality 1:1, selection 1:1, singleton=false, with supply function), which in turn contains the boolean attribute "B".
The supply function <b>defines </b>the value of attribute "B" in the single "V"-element in the given parent "Rows"-element.
For example, if you always set the value of "B" to true in the supply function, all checkboxes are checked.
If you wanted to check the checkboxes in rows with even index, you could implement it like
int i = parentElement.index(); /* row index */
node.currentVElement().setB(i % 2 == 0);
I believe you can even omit the creation and binding of the "V"-element because its cardinality is 1:1.
Armin
and now i found the problem to my context madness...
it's the doModify method:
during firstTime I retrieve data for my context node UTable--URows...
when leaving the view and coming back later on the same data is in UTable, which is bad. Instead I need a new sql-select which so far I did in an "else" branch... but because of that the checkboxes uncheck...
can i somehow replace the "else"???
matthias 😐
Hi matthias,
How to get the checked values?
In a table,
First column having check boxes mapped with a Value Attribute(boolean),
Second column having values mapped with a Value Attribute.
Now I have 5 check boxes along with values(separete column). I did this as you mentioned in your first post. I want to get the checked values.
Thanks in Advance
Raj..
Hi,
I think you are using 2 nodes to map to the table.
Since you have a model node.. create another node inside this of cardinality 1..1 and selection 0..1 and singleton - false.
Now add a boolean val attr to this node and map this to the check box.
-Modelnode
--Modelattr
--chkboxnode
-- chkattr
This will work !
Regards
Bharathwaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You want to select only one chechbox in the table.Is that your question ?
If so Consider the following ContextStructure
Data (NodeName)
->bol (boolean)
Just write the foolowing in "OnCheckBoxToggleAction"
int loc=wdContext.currentDataElement() .index();
for(int i=0;i<wdContext.nodeData().size();i++)
{
if(loc!=i)
wdContext.nodeData().getElementAt(i).setAttributeValue("bol",new Boolean(false));
}
This will uncheck the rest of the checkboxes in the table.
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 Matthias,
Check this weblog. This might be helpful.
/people/sap.user72/blog/2005/03/15/supply-functions-in-webdynpro
Regards,
Jaydeep
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hello Matthias
while creating an event for onToggle add a parameter of type "checkbox node element" eg: "selectedBox".
now in doModify() write this code:
IWDCheckBoxGroup chBox = (IWDCheckBoxGroup)view.getElement("checkboxID");
chBox.mappingOfOnToggle().addSourceMapping("checked","selectedBox");
// similarly if u want to know the index of the selected check box write this code:
chBox.mappingOfOnToggle().addSourceMapping("index","position");
// "position" another parameter which should be added while creating the event.
now in the onToggle event the status of selected node can taken.
regards,
Piyush.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.