cancel
Showing results for 
Search instead for 
Did you mean: 

Filling transparent container with a context node

Former Member
0 Kudos

Hi everybody,

I have lets say 20 server names in a context node. I would like to display them dynamically in a transparent container with for instance a colcount of 3. It would be perfect if I could use a LinkToAction UI element with an small image.

I know I could use a table, but I don't want to have a table design.

It should only looks like this, without adding dynamically UI elements in the wdModifyView method.

Server1234 Server7897 Server2342

Server3234 Server2342 ...

I also need a scrollbar. So anything like a transparent container with the possibility of using context nodes, would be perfect.

Is there anybody who is able to solve my problem?

Best regards

Joachim

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

First answer is that it can't be done the way you specify it.

The easiest way is to write code in wdDoModifyView, adding the IWDLinkToAction or IWDLinkToURL dynamicly to an existing scroll layout.

If you don't want to do that, you could perhaps use a table anyway. If you make it read-only, it can appear as just a empty list. The look of the table is modifieable in the Themes Editor in the portal.

A table can't be arranged in a 3 column manner you are looking for, but perhaps you could create a special node for the table with 3 calculated attributes fetching every third element from it's source node.

I.e. original node contains 21 elements.

Your special node contains calculated attributes that fetches element in the original node with index "element.index()3+0", "element.index()31", "element.index()*32".

Bind the table rowcount to a calculated attribute, and set it to the number of rows. Place the table inside a scroll container.

0 Kudos

thanks for your answer so far it really seems that adding UI elements in the wdModifyView method is the easiest way. But I am not quite sure how to use this method in connection with an action. For instance a button fires an action.

Then I have to add a static variable which I set in the action method and check the same variable in the wdModifyView after reloading the page.

But this seems a little dirty for me. Is this the way isn't it?

Best regards

Joachim

Update:

I don't need a static variable. I am able to use a value attribute in the context. This should be the better way isn't it?

Update V2:

Oh Armin you did this already.

Message was edited by:

Joachim Meyer

Message was edited by:

Joachim Meyer

Former Member
0 Kudos

Static variable will not work, use context attribute.

Armin

Former Member
0 Kudos

You could perhaps use parameter mapping on the links.

The same thing is used when a radio button group is used and you want to determine what radio button was selected.

For inspiration:

Answers (1)

Answers (1)

Former Member
0 Kudos

If the number of links to be displayed depends on the size of the node, you can either use a "data-driven" element like Table, ItemListBox etc., or you have to create individual UI elements programmatically in method wdDoModifyView().

In your case, you could create a TransparentContainer "LinkContainer" at designtime, layout=MatrixLayout, stretchedHorizontally=false, and add a LinkToAction for each node element.

Also create an action "ServerLinkClicked" with a parameter "serverName" (string) at design-time.

wdDoModifyView():


if ( wdContext.currentContextElement().getRebuildLinkContainer() )
{
  /* rebuild container */
  IWDTransparentContainer linkContainer = (IWDTransparentContainer) view.getElement("LinkContainer");
  linkContainer.destroyAllChildren();
  int cols = 3;
  for (int i = 0; i < wdContext.nodeServers().size(); ++i)
  {
    IServersElement server = wdContext.nodeServers().getServersElementAt(i);
    IWDLinkToAction link = (IWDLinkToAction) view.createElement(IWDLinkToAction.class, null);
    linkContainer.addChild(link);
    if ( i % cols == 0 )
    {
      link.createLayoutData(IWDMatrixHeadData.class); /* start new row */
    }
    else
    {
      link.createLayoutData(IWDMatrixData.class); /* same row */
    }
    link.setText(server.getName());
    link.setImageSource("whatever...");
    link.setOnAction(wdThis.wdGetServerLinkClickedAction());
    link.mappingOfOnAction().addParameter("serverName", server.getName()); 
  } 

  /* reset flag */
  wdContext.currentContextElement().setRebuildLinkContainer(false);
}

The "serverName" action parameter can be used to determine which link has been clicked ( a common handler is used for all links).

The flag "rebuildLinkContainer" should be set whenever the list of servers changes.

Armin

Message was edited by:

Armin Reichert