This discussion is archived
8 Replies Latest reply: May 2, 2013 2:47 AM by MonishM RSS

Appending space or new line to a string

user11978506 Newbie
Currently Being Moderated
While appending one string to other string we want to separate the 2 strings with a new line or space. From the BPM process we have appended a space character to the element and have passed it as data parameter to human task component but in the UI the fields are coming one after another and space disappeared. We are looking new line line character if it is not possible then need to help to append space.
  • 1. Re: Appending space or new line to a string
    Daniel Atwood Oracle ACE
    Currently Being Moderated
    When you get a chance, put your XPath expression that you're using to add space characters into your string. If you're using XPath, you do that by using "concat" and a ' ' between the two strings.

    Here's an XPath expression that concatenates two string variables (EmployeeFirstName and EmployeeLastName) from the payload and puts a space character between them. It then inserts a new empty line and then puts the third string (EmployeeStreetAddress) on the third line:
    concat(bpmn:getDataObject('EmployeeFirstName'),' ',bpmn:getDataObject('EmployeeLastName'), 
                         '<p> </p>',bpmn:getDataObject('EmployeeStreetAddress'))
    If you just wanted two lines, it would have instead looked like this:
    concat(bpmn:getDataObject('EmployeeFirstName'),' ',bpmn:getDataObject('EmployeeLastName'), 
                        '<p>',bpmn:getDataObject('EmployeeStreetAddress'),'</p>')
    Dan
  • 2. Re: Appending space or new line to a string
    user11978506 Newbie
    Currently Being Moderated
    Hi Dan,

    It is not solving the problem

    tried with the suggestion But It concatenated &lt;p&gt; as string. Instead adding new line it is adding &lt;p&gt; to the string like &lt;p&gt;data&lt;p&gt;. Can you please help. We can add spaces but not new line.

    Edited by: user11978506 on Jan 28, 2013 3:01 AM

    Edited by: user11978506 on Jan 28, 2013 3:02 AM

    Edited by: user11978506 on Jan 28, 2013 3:03 AM
  • 3. Re: Appending space or new line to a string
    Daniel Atwood Oracle ACE
    Currently Being Moderated
    1. What type of component are you using to display the string? If you're using a simple "Output Text" component, it's not going to work without adding 'escape = "false" into its source.
    2. Are you sure you are typing what I sent you correctly? Just going by what you entered in your second post, it looks like you might be typing:
    concat('<p>','some string','<p>')
    and not:
    concat('<p>','some string','</p>')
    This should have worked as well:
    concat('some string','<br>')
    Dan
  • 4. Re: Appending space or new line to a string
    user11978506 Newbie
    Currently Being Moderated
    We have tried with both of the option you have suggesred.
    but with the concat function wharever the string we are putting in ' ' is appendind as it is with the existing string.
    It is not generating neither newline nor a break tag.
    it look likes
    some string1&lt;p&gt;some string2&lt;/p&gt;
    or
    some string1&lt;br&gt;some strin2g&lt;/br&gt;

    but we want a new line in between two string
    like
    some string1
    some string2
  • 5. Re: Appending space or new line to a string
    Daniel Atwood Oracle ACE
    Currently Being Moderated
    Know this has been frustrating. I'm not able to see your form so I'm just guessing about this, but is it possible that you are using the "Output Text" component on your ADF form to display the text?

    Look at the source for your form and my guess is that you'll see something like this for your field:
                          <af:outputText value="#{bindings.Status.inputValue}"
                                         id="ot20"/>
    It is not recommended, but if you change it to this (setting escape to false) you should start seeing the new lines:
                          <af:outputText value="#{bindings.Status.inputValue}"
                                         id="ot20" escape="false"/>
    Changing the escape from its default of true to instead be false should let you see the new lines.

    A better solution is to use the "Output Formatted" component that is built for this.

    Dan
  • 6. Re: Appending space or new line to a string
    user11978506 Newbie
    Currently Being Moderated
    Actually we are using input text, input text does not have escape Property like Output Text, is there anyway we can set the same for input text also.
    We have also tried to replace the input text by the Output Text but after due to some unknow error page is not opening, not able to find any error in logs also.
    Need help.
  • 7. Re: Appending space or new line to a string
    Daniel Atwood Oracle ACE
    Currently Being Moderated
    <af:inputText> doesn't support this OOTB, but Frank Nimphius mentioned on the ADF forum (JDeveloper and ADF that you can do this using JavaScript or by adding a value change listener.

    Dan
  • 8. Re: Appending space or new line to a string
    MonishM Newbie
    Currently Being Moderated
    Following Combination worked for me.!
    1. concat('<p>','some string','<p>')
    2. <af:outputText value="#{bindings.Status.inputValue}"
    id="ot20" escape="false"/>

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points