Skip to main content

developerWorks >  WebSphere  >  Forums  >  IBM WebSphere Portlet Factory - Web Services and XML Schema  >  developerWorks

Merging two columns into one in a web service result set    Point your RSS reader here for a feed of the latest messages in this thread


     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
Permlink Replies: 4 - Pages: 1 - Last Post: Nov 5, 2009 5:59 PM Last Post By: SteveZag Threads: [ Previous | Next ]
JDWelsh07

Posts: 16
Registered: May 28, 2009 10:19:06 AM
Merging two columns into one in a web service result set
Posted: Nov 05, 2009 12:18:05 PM
Click to report abuse...   Click to reply to this thread Reply
I'm calling a webservice which returns data that looks something like this:

<result>
<accountNumber>12345</accountNumber>
<value>5000.00</value>
<currencyCode>USD</currencyCode>
...
</result>

When I'm displaying the results to the user I want to merge the value and currencyCode into a single column. I've tried using a Data Column Modifier to set a very small size on the currencyCode value instead of actually merging. This is close, but I need a right-aligned column header so this doesn't quite looks right.

Just wondering what the best approach is to merge two columns into one.

Thanks,

Dave
mburati

Posts: 1,684
Registered: May 10, 2006 03:35:21 PM
Re: Merging two columns into one in a web service result set
Posted: Nov 05, 2009 01:01:22 PM   in response to: JDWelsh07 in response to: JDWelsh07's post
Click to report abuse...   Click to reply to this thread Reply
There's a discussion and sample of merging two columns into one for display only, in the following WPF Best Practices thread.

http://www.ibm.com/developerworks/forums/thread.jspa?messageID=13951663

..mb1
JDWelsh07

Posts: 16
Registered: May 28, 2009 10:19:06 AM
Re: Merging two columns into one in a web service result set
Posted: Nov 05, 2009 05:42:18 PM   in response to: mburati in response to: mburati's post
Click to report abuse...   Click to reply to this thread Reply
Thanks for the reply. That almost solves my problem, but there is still one small detail. The value I wanted to display is to be formatted as a currency. I was using a Data Field Modifier to apply a NumberFormat to this value, but this does not take effect when I use this technique. Any recommendation as to how to best solve this problem? Do I have to write a custom method to apply the format and append the currency code? If so, how do I call a format function from a method? Or, is there a better approach?

Thanks,

Dave
SteveZag

Posts: 1,095
Registered: May 12, 2006 09:46:29 AM
Re: Merging two columns into one in a web service result set
Posted: Nov 05, 2009 05:58:48 PM   in response to: JDWelsh07 in response to: JDWelsh07's post
Click to report abuse...   Click to reply to this thread Reply
If you want to put it in a method, then you can use the java.text.NumberFormat class, which is what StandardFormatter uses.

If you just want the currency symbol in there, you can just put it in the text that you are displaying with the text builder. i.e.
${Variables/RowLoopVar/val1} at $$Variables/RowLoopVar/val2}
SteveZag

Posts: 1,095
Registered: May 12, 2006 09:46:29 AM
Re: Merging two columns into one in a web service result set
Posted: Nov 05, 2009 05:59:20 PM   in response to: SteveZag in response to: SteveZag's post
Click to report abuse...   Click to reply to this thread Reply
Shoot. I missed an open curly brace
${Variables/RowLoopVar/val1} at $${Variables/RowLoopVar/val2}
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums