[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 730
  • Last Modified:

Passing HTML from bean to JSP HTMLB TableView

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
natG
Asked:
natG
1 Solution
 
TimYatesCommented:
is that java code, or jsp code?

Can you give us a bit more?
0
 
natGAuthor Commented:
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
 
natGAuthor Commented:
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
natGAuthor Commented:
.
0
 
zzynxSoftware engineerCommented:
>> 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
 
natGAuthor Commented:
thanks zzynx
0
 
zzynxSoftware engineerCommented:
You're welcome
0
 
RomModCommented:
Asker resolved - the 125 points have been refunded and the question PAQ'd.

RomMod
Community Support Moderator
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now