cancel
Showing results for 
Search instead for 
Did you mean: 

how to add text and bind data in a textfield

Former Member
0 Kudos

hi,

how can i add some text in textfield with a bind data? is there any concatenating symbol like + in others?

thanx...

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi

From textfield what do u mean TextView, TextEdit .

In TextView to display data u can bind TEXT property of UI Element with context node. In Text view you can type text to be displayed at runtime.

For TextEdit UI Element, VALUE property can be bound to context which is required field for this UI Element.

For more specific reply Please elaborate your query.

Mandeep VIrk

Former Member
0 Kudos

hi,

actually i want to display some text in textview along with the data bind. i.e context is name and i want to display name with some other text. (hello!! <name>)

Former Member
0 Kudos

To concat a string with context value, Use this line of code



String Welcome_Text = "Hello";
Welcome_Text+wdContext.current<node >Element().get<attribute name>();

Mandeep Virk

Former Member
0 Kudos

itzz not working how can i do it in textvalue property?

Former Member
0 Kudos

I'll explain

Use textview UI element and bind its text property with context node as explained above.

Now go to Implementation tab and use above piece of code in wdDoInit().

Use this


public void wdDoInit()
  {
    //@@begin wdDoInit()
	String Welcome_Text = "Hello";
	wdContext.currentEmployeeElement().setName(" Viral");
	Welcome_Text += wdContext.currentEmployeeElement().getName();
	wdContext.currentEmployeeElement().setName(Welcome_Text);
	
    //@@end
  }

Mandeep Virk

Former Member
0 Kudos

Hi,

Lets say the attribute TextVal of type string is bound to the value property of the Textedit/InputField

now to have some text and the binded value



wdContext.currentContextElement().setTextVal("Test");

When the screen in rendered it will display "Test"



String str = "Test";
wdContext.currentContextElement().setTextVal(str +   wdContext.currentContextElement().getTextVal());

Above code will append Test to the existing value.

Regards

Ayyapparaj

Former Member
0 Kudos

You could add a calculated context attribute "displayName" and bind the "TextView.text" property to it.

Also add a new entry "formattedName" with a value like "Hello " into the message pool that provides the format used to decorate the name.

Implement the getter for the calculated attribute like


String getDisplayName(IContextElement element)
{
  String name = element.getName();
  if (name == null || name.trim().length() == 0)
    return "";
  
  return wdComponentAPI.getTextAccessor().getText(IMessage<ComponentName>.FORMATTED_NAME, new Object[] {name});
}

Armin