cancel
Showing results for 
Search instead for 
Did you mean: 

Design Studio 1.6 SDK component: How to read values from text area into a Text box without click

0 Kudos

Hi All,

I have tried to build an sdk component which generates random text every 5 secs into a Span area. I have linked this to the Text area class "sapMInputBaseInner" and able to view the generated text in Design studio Text area component.

I want to use the generated text into a text box for further analysis

example: TEXT_2.setText(TEXTAREA_1.getValue());

if (TEXT_2.getText()=="2018")

{

Filter other components on 2018

};


The above code is placed in on Change event script of TEXTAREA.

The problem here is, The on change event is not getting triggered automatically whenever there is a change in text and it requires a manual click (anywhere on application) to trigger the on Change event script.

So everytime i need to click somewhere on application to get the latest text out of TEXTAREA into the Text box.


Is there a way where in

1. We can bypass the manual click or trigger the on change event of TEXTAREA through SDK or timer?

OR

2. GetText(); property for the SDK component which auto updates and bring latest text into text box every 5 secs?


Thanks,

Abu


Accepted Solutions (0)

Answers (3)

Answers (3)

MustafaBensan
Active Contributor
0 Kudos

Hi Abu,

I have the following questions and comments:

1) I am curious to know what is the business use case for your SDK component of randomly generated numbers?

2) It seems to me that the main goal of your component is to generate a random number and then give the application the ability to query this number whenever it is generated to perform further processing. Rather than applying a hybrid approach that relies on manual integration with a TextArea component to retrieve the value, you should build the SDK component to be self-contained. I suggest you redesign your SDK component as follows:

(i) Instead of linking the generated random number to the Text Area class, define a Value property for your component and update this value with the random number;

(ii) Define a custom On Change event for your SDK component and trigger this whenever the Value property is updated in step (i)

With the above approach, you can then place the if then code in the On Change event of the SDK component and check the current value of the number by using the getValue() method of your SDK component. This is a much cleaner solution than trying to integrate class "sapMInputBaseInner" with the Text Area component.

Regards,

Mustafa.

0 Kudos

Hi Mustafa,

Thank you for the response.

The business use case here is enabling DS with voice commands. Therefore i tried to develop a SDK using google API which will do Speech to text conversion and send the text output to DS for further analysis. I mentioned Random generation of numbers just to keep the focus on the problem and not the main requirement.

I followed your posts and other threads to try to fit in the Speech recognition java script in the SDK and sought help from Java developers. They suggested to directly integrate with class "sapMInputBaseInner". But this method is not working as mentioned earlier.

Regarding your suggestion to define a value property, I have tried defining a Text property and hardcoding text "setvalue". But i am unable to get the "setvalue" in a text box TEXT_1.setText(AUDIO_1.getText()); (in Start up script).


Please let me know a way forward.


Thanks,

Abu

ZTL

class com.sap.voice.Audio extends Component { String getText() {* return this.Text; *} }
XML


		<property id="Text" type="Text" title="" bindable="true">
		</property>

Component.js


	this.Text = function() {
		
	
		this.getText();


				};
		
	this.getText = function() {
		this._Text= "setvalue";
	}	
0 Kudos

Hi Arijit,

Thanks for your response.

I had tried the blur() earlier to remove the focus, but it doesn't work.

these are the things which i tried to trigger in the console during runtime.

$('#TEXTAREA_1_control-inner').blur();

$('#TEXTAREA_1_control-inner').keyup();

$('#TEXTAREA_1_control-inner').keydown();

Please let me know where i am going wrong.

Thanks,

Abu

arijit_das
Active Contributor
0 Kudos

The problem is value in the text area updates only when the focus moves out of the text area. So, TEXTAREA_1.getValue() will not return the exact value unless the focus moves away. This behavior is by design, hence you need an extension which provides an onKeyUp or onKeyDown event (http://www.java2s.com/Tutorial/JavaScript/0200__Form/TextareaonKeyUp.htm).