Solved

Passing HTML from bean to JSP HTMLB TableView

Posted on 2004-08-02
8
689 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:natG
ID: 11696358
.
0
 
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

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
mysql jsp example issue 32 51
Java: The Public Class Main 4 32
SequenceInputStream example 3 19
Fast way to search item into Java Array (Rhino compatible) 2 31
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

830 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