Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 971727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:00:35+00:00 2026-05-16T03:00:35+00:00

So, I am getting as return parameter from an already established code a StringBuilder

  • 0

So, I am getting as return parameter from an already established code a StringBuilder element, and I need to insert it into my GWT app. This StringBuilder element has been formatted into a table before returning.

For more clarity, below is the code of how StringBUilder is being generated and what is returned.

private static String formatStringArray(String header, String[] array, int[] removeCols) {
    StringBuilder buf = new StringBuilder("<table bgcolor=\"DDDDDD\" border=\"1\" cellspacing=\"0\" cellpadding=\"3\">");

    if (removeCols != null)
        Arrays.sort(removeCols);

    if (header != null) {
        buf.append("<tr bgcolor=\"99AACC\">");
        String[] tokens = header.split(",");
        //StringTokenizer tokenized = new StringTokenizer(header, ",");
        //while (tokenized.hasMoreElements()) {
        for (int i = 0; i < tokens.length; i++) {
            if (removeCols == null || Arrays.binarySearch(removeCols, i) < 0) {
                buf.append("<th>");
                buf.append(tokens[i]);
                buf.append("</th>");
            }
        }
        buf.append("</tr>");
    }

    if (array.length > 0) {
        for (String element : array) {
            buf.append("<tr>");
            String[] tokens = element.split(",");
            if (tokens.length > 1) {
                for (int i = 0; i < tokens.length; i++) {
                    if (removeCols == null || Arrays.binarySearch(removeCols, i) < 0) {
                        buf.append("<td>");
                        buf.append(tokens[i]);
                        buf.append("</td>");
                    }
                }
            } else {
                // Let any non tokenized row get through
                buf.append("<td>");
                buf.append(element);
                buf.append("</td>");
            }
            buf.append("</tr>");
        }
    } else {
        buf.append("<tr><td>No results returned</td></tr>");
    }

    buf.append("</table>");
    return buf.toString();
}

So, above returned buf.toString(); is to be received in a GWT class, added to a panel and displayed… Now the question is: how to make all this happen?

I’m absolutely clueless as I’m a newbie and would be very thankful for any help.

Regards,
Chirayu

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:00:35+00:00Added an answer on May 16, 2026 at 3:00 am

    Could you be more specific, Chirayu? The “already established code” (is that a serlvet? Does it run on server side or client side?) that supposedly returns a StringBuilder, obviously returns a String, which can be easily transferred via GWT-RPC, JSON, etc.
    But like Eyal mentioned, “you are doing it wrong” – you are generating HTML code by hand, which is additional work, leads to security holes (XSS, etc) and is more error-prone. The correct way would be:

    • Instead of generating the view/HTML code on the server (I’m assuming the above code is executed on the server), you just fetch the relevant data – via any transport that is available in GWT
    • On the client, put the data from the server in some nice Widgets. If you prefer to work with HTML directly, check out UiBinder. Otherwise, the old widgets, composites, etc way is ok too.

    This way, you’ll minimize the data sent between the client and the server and get better separation (to take it further, check out MVP). Plus, less load on the server – win-win.

    And to stop being a newbie, RTFM – it’s all there. Notice that all the links I’ve provided here lead to the official docs 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a warning: Return makes pointer from integer without a cast for this
I'm getting a weird return when executing this query : SELECT * FROM rrp
How to retrieve data from sqlite database? Getting return value zero. -(id)init{ if(self==[super init]){
What return type should one return from a method that is getting rows from
I have two foreach statements. The variable from one one is somehow getting into
I'm getting a cannot convert from 'int' to 'TValue' in the following code. How
Im getting the following error on the code I transleted from C# to VB.NET
I am getting the error: Failed to convert parameter value from a Int64 to
The error I'm getting: error C2664: 'v8::FunctionTemplate::New' : cannot convert parameter 1 from 'v8::Handle<T>
I want to paste table name as function parameter and function need to return

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.