cancel
Showing results for 
Search instead for 
Did you mean: 

How to assign a value to UIElement.

konchada_saikrishna
Active Participant
0 Kudos

Hi all,

I have the rootUicontainer as this.

root

|_msg(textview)

|_name(inputfield)

|_Table1

|_one(checkbox)

|_two(Inputfield)

How to assign value to the "msg" at runtime, also table1 is binded to context, I want to make the "one" field as checked and readonly at run time. Please help me with code in Webdynpro java.

Thanks in advance.

With regards,

Sai krishna.

Accepted Solutions (1)

Accepted Solutions (1)

suresh_krishnamoorthy
Active Contributor
0 Kudos
konchada_saikrishna
Active Participant
0 Kudos

Hi suresh,

I could not found code for updating column value in a row of a UItable prgramatically.

Former Member
0 Kudos

Hi

Could you explain your requirement again clearly.

Then I will help you.

Thanks,

Lohi

suresh_krishnamoorthy
Active Contributor
0 Kudos

Hi,

Create Node and Value attribute structure like this and bind to the table(Sample Node).

Context

Sample(Node)

-Key(value attribute)

-Attribute(value attribute)

-NewValue(value attribute)

Use the following code to display two rows of record.

IPrivate<View>.ISampleElement reportElement = wdContext.createSampleElement();

reportElement.setKey("10");

reportElement.setAttribute("English");

reportElement.setNewValue("System");

wdContext.nodeSample().addElement(reportElement);

reportElement = wdContext.createSampleElement();

reportElement.setKey("11");

reportElement.setAttribute("Tamil");

reportElement.setNewValue("Value");

wdContext.nodeSample().addElement(reportElement);

Hope this will help you

Regards, Suresh KB

konchada_saikrishna
Active Participant
0 Kudos

Hi Lohi,

Thanks for your interest.

My problem is that I have a bapi which fetches a table with two fields(fname(char 15), fcheck(char 1))from back end as fcheck "x" = checked, " " = unchecked I want to display it as

Fcheck, fname

-


[] name

[] age

[] salary

:

:

up to 19 rows.

-


// [] mean check box.

I tried binding it to the UITable of the view, it raises an error as fcheck cannot be mapped to boolen since it is a char in the model.

So I need to iterate the model node in the view context, read each fcheck value and make the uitable>fcheck>celleditor to checked if it is "X" and viceversa.

Finally when the user checks some of the check boxes and click the save button then again iterate the uitable read each fcheck cell editor, if checked make the view context>modelnode>fcheck value to "X" & viceversa, them as import params to another bapi to store at backend.

or if there is any other way to solve my problem like if we can convert the fcheck datatype to boolean in bapi or in the code(typeconversion) setter/getter methods help me with code thanks in advance.

Former Member
0 Kudos

Please read my answer in the other thread again.

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi Armin,

Thank you, actually I was working with your code in previous thread trail & error method. I am new to webdynpro I didn't get what you mean there, but I understood that there would be some code like reading a char and return a boolean for every access. Please tell me where & how to create caliculated attribute and how work with it.

I would be Thankful to u.

Former Member
0 Kudos

You have a Table UI element. Its "dataSource" property is bound to a (model?) node, say "Rows".

Add an attribute "Checked" to this node, type=boolean, calculated=true, readOnly=false.

There will appear two new methods in your view controller for getting and setting the value of the calculated attribute. Implement them as I showed in the other thread.

If you cannot add attribute "Checked" directly under node "Rows" (because of structure binding), add a helper (value) node "Helper" under "Rows", cardinality=1:1, selection=1:1, and add attribute "Checked" under node "Helper".

(In this case, the code for the getter and setter has to be changed slightly)

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi Armin,

As u said I created the "helper" node with attribute "checked" under the "model" node.

I binded the UITable-->Checkbox field to this "checked" attribute of "Helper" node.

But in the get method u said to have "X".equalsIgnorecase(gethelperchecked()); as the return value. It is type mismatch for the method equalsIgnoreCase which takes string values as parameters. How to procede next.

Former Member
0 Kudos

No, the get-method converts the String attribute (how is it called in the model node?) to a boolean.

Say your model node is named "Rows" and the attribute that stores "x" or " " is named "Cross".

Then you have to write

boolean getChecked(IHelperElement element)
{
  IRowsElement row = (IRowsElement) element.node().getParentElement();
  return "x".equalsIgnoreCase( row.getCross() );
}

Setter works similarly.

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi Arman,

It's working great, but the value is displayed only when u select that particular row, they all look unchecked initially, how to make them visible.

However thanks a lot.

Former Member
0 Kudos

How is the "Rows" node filled?

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi,

Initially my backend data contains 19 rows where 4 are already checked, here in the view they all look unchecked, when I select a row then it's value is displayed checked / unchecked as in backend.

Former Member
0 Kudos

Can you post the code where the backend (model) is called?

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi,

The model binding is done at design time, I did'nt code for that.

Former Member
0 Kudos

But there is somewhere in the code a statement like

rfc.execute();
nodeOutput.invalidate();

Are you calling invalidate() correctly?

Armin

konchada_saikrishna
Active Participant
0 Kudos

Hi,

Yes, Actually I have a dropdown with alist, on selction I call this "getlist(selected value)" of custom controller.

the getlist method of cust controller

public void Getfileds( java.lang.String option )

{

//@@begin Getfileds()

Zbapi_Config_Flds_Input input = new Zbapi_Config_Flds_Input();

wdContext.nodeZbapi_Config_Flds_Input().bind(input);

// setting the import parameter

input.setForm_Type(option);

try

{

wdContext.currentZbapi_Config_Flds_InputElement().modelObject().execute();

}

catch(Exception ex)

{

ex.printStackTrace();

}

wdContext.nodeOutput().invalidate();

//@@end

}

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

1) add one attribute to msg text view of text property and add the code in the Init() method.

wdContext.currentContextElement().set<declaredattribute>("msg");

2)create an attribute as boolean mapped to checked and write the code in init method.

wdContext.currentContextelement().set<attrname>(true);

the property readonly as True or create an attribute as boolean. map to readonly.

wdContext.currentContextelement().set<attrname>(true);

This might helps otherwise post your issues.

Thanks

Lohi.

konchada_saikrishna
Active Participant
0 Kudos

Hi Lohitha,

Thank you, I want to update values of the UIElements in the view. I could update the "msg" element, I want to Iterate in the UITable, make some of the values in the row to checked and readonly based on condition. You said wdContext, it is the parent node for View Context it is not UIRootContainer am I right.