Solved

Passing HTML from bean to JSP HTMLB TableView

Posted on 2004-08-02
8
695 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Apache Camel - Unable to propagate JMS Header Properties between Request - Response 3 40
Java Restore security prompts not working 10 239
Java 8 to Java 6 8 41
jmeter usage 4 60
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 …
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…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Suggested Courses

737 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