cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the vlaue from an input field without hitting the enter button ?

Former Member
0 Kudos

Hello All,

Is there some way to read the values of an input field that was filled in by an user eg ..

String userEntry = wdContect.<UIElement>.value;

So far, I am only able to achieve this using the onEnter property whoch really is not very user friendly since I can only read in the values only if the user hits enter.

Any help will be appreciated. Thank you.

from

Kwok Wei

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

you need the model attribute then:

if you want to save a bit time, you can use drag and drop in the mapping view and drag the model from the right(controller's context) to a node on the left (view context). select the new attribute and it is then created automatically.

Message was edited by: Marius Wolfenski

Former Member
0 Kudos

Thank you everyone for the kind inouts. Although it does not really perform what I want it to do, it does give me a better understanding particular on the context mapping. I will love to award points to everyone who have so kindly contributed to my queries but as I cannot split the points among you guys, I guess I can only award to Pascal den for his clearer contributions.

Thanks again everyone.

from

Kwok Wei

Former Member
0 Kudos

You don't need the InputField.onEnter action to get the changed value on the server. The value is transported on any server round-trip.

So simply bind the InputField.value property to an appropriate context attribute and you have access to the changed value via this attribute in every view controller method.

Armin

Former Member
0 Kudos

Hello Armin,

Will it be possible that you post a sample code of how the binding may look like. I am a total newbie here and has been trying it out with no luck so far. Any sample coding/examples will be greatly appreciated. Thank you..

from

Kwok Wei

Former Member
0 Kudos

In NWDS: Select the InputField in the Outline view, look at the "value" property in the properties sheet. Select there the button "..." that opens the view controller context, select the context attribute to which you want to bind the "value" property, done.

Armin

Former Member
0 Kudos

WebDynpro hides a lot of HTTP-protocol specific details, but you have to understand that it is simply impossible to make transparent one thing:

It is impossible to get value user has typed in clinet (browser) unless some Action (hidden HTTP request) is executed (onEnter action, onAction in button || link2action etc.)

VS

Message was edited by: Valery Silaev

Former Member
0 Kudos

Hello VS,

Thank you very much for you feedback. The reason why I'm asking is because we have a application (developed on dynpro) and it seems that it is able to pickup the value that the user has enetered without any onEnter actions. All I need to do is hit the Send button and the value that was enterd on the client end will automatically be picked up. So I guess theres no way in WD that we can do something similar based on you feedback and Anilkumar's example.. ?

from

KWok Wei

Former Member
0 Kudos

If you have properly mapped the UI element to a Context attribute, the entered value should be available there after clicking the Send button.

Former Member
0 Kudos

Hello Pscal,

Have you an personal experience with this or its a logical hunch ?

from

Kwok Wei

Former Member
0 Kudos

1. Create a value attribute (MyText) in the controller context

2. Create a value attribute (MyText) in the view context

3. Map view context attribute to controller context attribute

4. Create InputField in the view and map the "value" attribute to the MyText view context attribute

5. Create Action on view (Send)

6. Create Send button and specify Send action as onAction attribute

7. Create executeSend() method on controller

8. onActionSend() implementation:

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

{

//@@begin onActionSend(ServerEvent)

wdThis.wdGet<controllername>Controller().executeSend();

//@@end

}

9. executeSend() implementation:

public void executeSend( )

{

//@@begin executeSend()

// Get MyText

String MyText = wdContext.currentContextElement().getMyText();

}

Former Member
0 Kudos

Thank you all very much Pascal and Armin.

I have jus followed your suggestions and hit a problem. The value in the UI element is binded to a value attribute "fullName" (view context )which in turns I guess mus be mapped to 2nd value attribute (controller context) for the value to be reflected correctly ? Unfortunately, this 2nd value attribute is actually a model attribute which is not possible to be mapped ?

from

Kwok Wei

Former Member
0 Kudos

You can also pass the value from the onAction method to the executeSend method.

You must then first add a parameter to the executeSend method and then retrieve the value from the view context attribute and pass it in the call to executeSend:

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

{

//@@begin onActionSend(ServerEvent)

String myText = wdContext.currentContextElement().getMyText();

wdThis.wdGet<controllername>Controller().executeSend(myText);

//@@end

}

In this case you must also change the executeSend method so it assigns the value of MyText to the correct model parameter.

(Please award points if you find our answers helpful)

Former Member
0 Kudos

Hi,

You need to make use of context for this.

ex: wdCOntext.currentcontextElement().get<<Attribute>>

Regards, Anilkumar