cancel
Showing results for 
Search instead for 
Did you mean: 

how get context value form a dynamic created node

Former Member
0 Kudos

Hi all,

I have build my own dynamic view. In this view I use also a dynamic created Node. When I have more rows in my Node I see every row with context of the last row of the dynamic Node.

this is the source I use.


for (int x = 0; x < dynTabNode.size(); x++) 
{
  dynTabNode.setLeadSelection(x);
  IWDGroup group = (IWDGroup)view.getElement("Group_name");
  IWDAttributeInfo aiName = wdContext.getChildNode("DayNode", IWDNode.LEAD_SELECTION).getNodeInfo().getAttribute("Name");
  IWDCaption name = (IWDCaption) view.createElement(IWDCaption.class, null); 
  name.bindText(aiName);
  group.addChild(name);
		
  for (int i = 8; i < 18; i++) 
  {
    int teller = i * 100;
    IWDGroup group1 = (IWDGroup)view.getElement("hour" + teller);
    for (int z = 0; z < 12; z++)
    {			
      IWDImage image = (IWDImage) view.createElement(IWDImage.class, "Image" + teller + "_" + x);
      image.setWidth("10");
      image.setHeight("24px");
      image.setBorder(0);
      IWDAttributeInfo att = dynTabNode.getNodeInfo().getAttribute("hour" + teller);
      image.bindSource(att);
      group1.addChild(image);
      teller = teller + 5;
    }
}

How can I read my Node row for row?

Richard

Edited by: Armin Reichert on Jul 28, 2008 5:03 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi,

Could you just try changing this line

IWDAttributeInfo aiName = wdContext.getChildNode("DayNode", IWDNode.LEAD_SELECTION).getNodeInfo().getAttribute("Name");

name.bindText(aiName);

to

String Name = wdContext.getChildNode("DayNode", IWDNode.LEAD_SELECTION).getCurrentElement().getAttributeAsText("Name");

name.setText(Name);

Regards,

Murtuza

Former Member
0 Kudos

What exactly do you see? I would guess that all captions have the same text, right?

Armin

Former Member
0 Kudos

Hi Armin,

That's the problem I'am having.

Richard

Former Member
0 Kudos

The reason is that all these Caption UI elements are bound against the same context attribute. At runtime this will be resolved to the attribute value of the lead-selected node element. In this example you can fix this by not binding the "text" property but setting it to the attribute value of the iterated node element:


for (int x = 0; x < dynTabNode.size(); x++) 
{
  dynTabNode.setLeadSelection(x);
  IWDGroup group = (IWDGroup)view.getElement("Group_name");
  IWDCaption name = (IWDCaption) view.createElement(IWDCaption.class, null); 
  IWDNode dayNode = wdContext.getChildNode("DayNode", IWDNode.LEAD_SELECTION);
  String text = (String) dayNode.getElementAt(x).getAttributeValue("Name"); 
  name.setText(text);
  /*
  IWDAttributeInfo aiName = dayNode.getNodeInfo().getAttribute("Name");
  name.bindText(aiName); 
  */
  group.addChild(name);
  ...
}

(I assume here that the node "DayNode" has the same size as dynTabNode. No idea if this assumption is correct)

But this would not help for editable elements where you need to bind the edited property.

Armin