cancel
Showing results for 
Search instead for 
Did you mean: 

display problem

Former Member
0 Kudos

Hi All,

I have following line of code in my program

Object attributeValue = wdContext.currentContextElement() .getAttributeValue( fldName);

Now I have to display the "attributeValue" on my output screen after this line of code is processed. What is the code for that?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI,

First let me say wat I understood.

U want to display the value of the variable <b>attributeValue</b> to output.

If yes, u can display it in a textView by

wdContext.currentContextElement().setText(""+attributeValue);

where <b>Text</b> is the context variable bount to textView

Regards

Fahad Hamsa

Former Member
0 Kudos

Hi Hamsa,

Your understood my requirement correctly but is there any other way without taking help of the context attribute.

Thank you.

Former Member
0 Kudos

HI,

U can make use of message manager for this as

wdThis.wdGetAPI().getComponent().getMessageManager().reportSuccess

(""+attributeValue);//FOR SUCCESS MESSAGE

wdThis.wdGetAPI().getComponent().getMessageManager().reportWarning(""+attributeValue);//FOR WARNING MESSAGE

wdThis.wdGetAPI().getComponent().getMessageManager().reportException(""+attributeValue,false);//FOR ERROR MESSAGE

If u want to set the value in the same fashion that u got the value, u can try this

wdContext.currentContextElement().setAttributeValue("Text",attributeValue);

But here also, Test is a context variable

Regards

Fahad Hamsa

Answers (4)

Answers (4)

former_member751941
Active Contributor
0 Kudos

Hi Bharath,

You can display the value using “MessageManager” or using “popup” also

Take a Button (say “ShowValue”)

1> Inside the action of the button (ShowValue) use the code

Object attributeValue = wdContext.currentContextElement() .getAttributeValue("fldName");

wdComponentAPI.getMessageManager().reportSuccess("Arrtribute Value : "+attributeValue.toString());

2> To display the value using popup.

Go to the Methods tab. Create an “Event handler” (say “Ok”)

Inside the action of the button(ShowValue) use the code

Object attributeValue = wdContext.currentContextElement() .getAttributeValue("fldName");

String dialogText="You have Entered : "+attributeValue.toString() ;

IWDConfirmationDialog confDialog = wdComponentAPI.getWindowManager().createConfirmationWindow(dialogText,wdThis.wdGetAPI().getViewInfo().getViewController().findInEventHandlers("Ok"),"Ok");

confDialog.show();

Regards,

Mithu

arun_srinivasan
Contributor
0 Kudos

Hi

Create a value attibute va and bind it to textview which you want to diplay it in next line

Object attributeValue = wdContext.currentContextElement() .getAttributeValue( fldName);

wdContext.currentContextElement().setva(""+attributeValue);

If you want to display the value as a meassage

Object attributeValue = wdContext.currentContextElement() .getAttributeValue( fldName);

wdComponentAPI.getMessageManager().reportSuccess(""+attributeValue);

Also go through this API for working with different type of mesage

https://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/progmodel/api/IWDMessageManager....

Thanks and Regards,

Arun

Message was edited by:

Arun Srinivasan

Former Member
0 Kudos

Hi All,

My display problem is solved but one more problem occured .

I am using one "save" button here.If we click that button the data entered is saved.

For that i wrote code in "onactionsave" method.In that method I am checking the

Mandatory data in the input field.If data is not entered in the inputfield then it should give error message.It is working fine for the first time.But if i enter data in the input field and press save ,my data is saving and then if I remove the data using "backspace" and then again if i press " save" ,it is not giving the error message.

Thanks in advance.

Former Member
0 Kudos

HI,

Do like this

String var=wdContext.currentContextElement().get<Val>();

if(var==null)

{

wdComponentAPI.getMessageManager().reportException("Enter value",true);

}

else if(var.trim().equals(""))

{

wdComponentAPI.getMessageManager().reportException("Enter value",true);

}

else

{

wdComponentAPI.getMessageManager().reportSuccess("Success");

}

Regards

Fahad Hamsa

arun_srinivasan
Contributor
0 Kudos

hi

code

//@@begin javadoc:onActionsave1(ServerEvent)

/** Declared validating event handler. */

//@@end

public void onActionsave1(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionsave1(ServerEvent)

String Name=wdContext.currentContextElement().getVA_Name();

if(Name.trim() == null)

{

wdComponentAPI.getMessageManager().reportWarning("Please enter the Name");

}

else

{

wdComponentAPI.getMessageManager().reportSuccess("Please enter Name is "+Name);

wdContext.nodeVN_Dropdown().moveFirst();

}

//@@end

}

Regards,

Arun

abhimanyu_lagishetti7
Active Contributor
0 Kudos

Hi

You can also use wdThis.wdGetComponentAPI().getMessageManager().reportSuccess( attributeValue.toString() );

Regards

Abhimanyu L

Former Member
0 Kudos

Hi,

You dont need to get the value of the attribute.

Instead create a UI element TextView/InputField and bind the property of the UI element to the context attribute.This will directly show the value in the view.