Solved

Passing HTML from bean to JSP HTMLB TableView

Posted on 2004-08-02
8
673 Views
Last Modified: 2010-08-05
Hello,

I am building an HTMLB Default TableView with a 2 dim array using data from a SAP Jco TableView and adding a column to display a link to a popup with details (if available) for each row. I am trying to store the HTML code in this column and then pass it to the JSP via the TableView. SO, I need some way to tell the JSP to evaluate the html.  Here is some code:

   if ((thisCol == numCols) && (detailsExist == true))
   {
        data[thisRow][thisCol] = "<a href='somelink here'>Details...</a>";
    }
   else if (thisCol == numCols) data[thisRow][thisCol] = "";
   else data[thisRow][thisCol] = comphisdataModel.getValueAt(thisRow+1, jcoCol).toString();                        
I actually tried this first with <b> tags just to see if it works and it won't. Obviously I will need something more than just passing the tags right through-- I tried &lt and &gt but whatever I do it always displays just like it's written.      

Hope this is clear.

Thank you,

NatG                  
                  
0
Comment
Question by:natG
8 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 11695372
is that java code, or jsp code?

Can you give us a bit more?
0
 

Author Comment

by:natG
ID: 11695453
That is the java code. It loads the array with data (including this column) and passes it to an HTMLB tableview. In the JSP there isn't direct interaction with the content itself, just the tableview tags. Here is the jsp code:

        <hbj:tableView  id="DefTable"
                          model= "MyCompHistBean.model"
                          design = "ALTERNATING"
                          headerText="<b><center>def table Compensation History</center></b>"
                          headerVisible="true"
                          fillUpEmptyRows = "true"
                          footerVisible = "true"                        
                          navigationMode = "BYLINE"                        
                          onNavigate = "onNavigation_CHTable"
                          visibleFirstRow = "<%= MyCompHistBean.getVisibleRowCHTable() %>"
                          visibleRowCount = "3"
                          selectionMode = "SINGLESELECT"
                          >      
          </hbj:tableView>

Here is a more complete snippet of the java (bean) code. Most of this is not relevent to the problem I'm having but it may give you a better sense of what I'm doing:

public void createDisplayTable()
{
 Object[] columns = null;
 Object[][] data = null;

 int numRows = comphisdataModel.getRowCount();
 int numCols = comphisdataModel.getColumnCount();
 boolean detailsExist = false;
 
//            System.out.println(numRows+ " rows.");
//            System.out.println(numCols+ " columns.");
//                        
 columns = new String[numCols+1];// extra column for details link
 data = new String[numRows][numCols+1];
 
 for (int thisCol=0; thisCol<numCols; thisCol++)
 {      
  columns[thisCol] = comphisdataModel.getColumnName(thisCol+1);
 }
 columns[numCols]="";
 
 for (int thisRow=0; thisRow<numRows; thisRow++)
 {
  int jcoCol=1;//the actual col in the jco table, since we are skipping some
  for (int thisCol=0; thisCol<=numCols; thisCol++)// using <= b/c need 1 col more than in jco table
   {      
    if(thisCol==1) jcoCol++;// skip ENDDA column
 

   if (thisCol==0)//while on 1st column look for matching rows in the details table
   {
    //System.out.println("check for DETAILS LOOP");
    for (int a=0; a < detailsModel.getRowCount(); a++)
    {
     //BEGDA is in Column 8 of details table - should use const or find dynamically
        if (detailsModel.getValueAt(a+1, 8).toString().trim().equals
        (comphisdataModel.getValueAt(thisRow+1, jcoCol).toString().trim()))
      {// match for BEGDA on details table exists
       detailsExist = true;
      }
     }
   }
   if ((thisCol == numCols) && (detailsExist == true))
   {
    data[thisRow][thisCol] = "<b>Details...</b>";
   }
   else if (thisCol == numCols) data[thisRow][thisCol] = "";
   else data[thisRow][thisCol] = comphisdataModel.getValueAt(thisRow+1, jcoCol).toString();                        
   
 
   if (thisCol<numCols) jcoCol++;//advance jcoCol - must occur at end of the loop
  }
  detailsExist = false; //reset for next row
 
 }
 
 model = new DefaultTableViewModel(data, columns);
 setModel(model);
 
}

Hope this gives a better picture. Thanks for the quick response.
0
 

Accepted Solution

by:
natG earned 0 total points
ID: 11696351
Well, I found  asolution myself.

For anyone who's interested, there is a command that apparently instructs the JSP not to encode the info being passed. First I found the column in the TVM and then set encode to false:

            TableColumn myColumn = model.getColumnAt(6);
            myColumn.setEncode(false);

That did the trick. Thanks to anyone/everyone who was looking into this for me.

NatG
0
 

Author Comment

by:natG
ID: 11696358
.
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 37

Expert Comment

by:zzynx
ID: 11697629
>> Well, I found a solution myself
In that case, you better request for a delete of this Q with a refund of the points.

Here's how:
Post a zero-point question in http://www.experts-exchange.com/Community_Support/

Subject: Please Delete with Refund
Body: Please delete this question:
http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_21079350.html
0
 

Author Comment

by:natG
ID: 11698977
thanks zzynx
0
 
LVL 37

Expert Comment

by:zzynx
ID: 11699038
You're welcome
0
 

Expert Comment

by:RomMod
ID: 11699382
Asker resolved - the 125 points have been refunded and the question PAQ'd.

RomMod
Community Support Moderator
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now