on 01-02-2008 9:03 PM
Hi all,
We have one Comment field on Portal screen that is given by the user (User may press enter while giving the comments). We are sending that field value to R3 through RFC and when we are getting back that comment field value from R3 we need to identify the Enter pressed by the user. We are writing the code for identifying "/n" in that comments field but that is not working. Can anyone help me out in this? This is really urgent.
Thanxs in advance!!!
Hi,
You can write the code onActionEnter for your UI Element. In this you can append a "\n" to the comment everytime an enter is pressed. The comment text you can get from the context attribute mapped to the UI element.
Suppose you have the text entered as "AAAA" and an enter pressed and then "BBBB". Now after appending the "\n" it will go to backend as "AAAA\nBBBB ".
If you take the same data while retrieving it, i.e without any manipulation for "AAAA\nBBBB " the string from the backend, it will display as:
AAAA
BBBB
in your UI. Hope you are using TextEdit UI for user comments.
thanks & regards,
Manoj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Manoj,
Thanxs for th reply.. I am using TextEdit for comments field.Problem is when I am getting the comments field I have find out where user has press the Enter key because I want to replace the NewLine with space. For eg: If user has enter
AAAA
BBBB
then when I am getting back I want to show that as
AAAA BBBB. When I am writing the code for replacing /n with space it is not recognizing /n. Is there any way to do this?
Hi Gurmat,
Now i got your exact problem.
Hence i am extremely sorry for my previous reply which was completely wrong.
There is no onEnter action associated with textEdit UI. Therefore it is not possible to track when user has pressed enter. Another thing is that if you try to print the comments entered by the user as:
AAAA
BBBB
it will print it as normal AAAA BBBB, but in textEdit it will take it as:
AAAA
BBBB
If the text entered is:
AAAA BBBB
then also it will print it as normal AAAA BBBB.
Well i hope the other gurus here will have some idea about the wrapping of textEdit UI.
thanks & regards,
Manoj
Hi Gurmat,
You can find out and replace the new-line character with any character in TextEdit using String methods like this.
e.g. If the context attribute text is bound to the TextEdit.
You need to get the attribute and replace it
String newText = wdContext().currentContextElement().getText().replace('\n','#' );
Now newText contains the string which replaces '\n' with '#'
In place of '#' you can use whichever character you want.
By default one space i.e.' ' is added at the end of each line.
regards,
Siva
Hi Gurmat,
It is surprising. Actually I too had doubt regarding this, so I tried and worked out successfully before posting the previous message. I used the same code to replace '\n'.
I have given the below input in TextEdit:
Siva (pressed enter)
Rama
I got output as:
Siva #Rama
I don't think you are doing this mistake but just to confirm: Are you using single quotes ' ' or double quotes ""?
You must use single quotes.
regards,
Siva
Hi Gurmat and Manoj,
Do you want to replace the TextEdit too? I thought only to print or send to backend. No problems. We can do change in TextEdit as well.
My input in TextEdit is:
How
are
you
Manoj?
After button click I got output in TextEdit and TextView(I used button to trigger event):
How are you Manoj?
In onActionButton() my code is:
StringBuffer buffer = new StringBuffer(wdContext.currentContextElement().getText());
for (int i = 0,index=buffer.indexOf("\n"); i < buffer.length(); i++) {
if(i==index){
buffer.replace(i-1, i+1," ");
index = buffer.indexOf("\n");
if (index==-1)
break;
}
}
In StringBuffer use "" only
regards,
Siva
Hi Gurmat,
I did not get clear idea of your problem. I assume for comment input field you are using onEnter action and appending "/n" to the text.
You need to use "\n" as a new-line character but not "/n".
regards,
Siva
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.