Skip to Content
author's profile photo Former Member
Former Member

Displaying a link in a tableView

Hi,

I am trying to display a link in column of a tableview in a jsp page.

the source code is:

public void initAttachmentsModel() {

Vector colName = new Vector(2);

colName.addElement("File Name");

colName.addElement("URL");

attachmentsModel = new DefaultTableViewModel(attachmentsList, colName);

TableColumn col = attachmentsModel.getColumn("URL");

col.setType(TableColumnType.LINK);

col.setEncode(false);

}

But no link is displayed within the tableview.

I also tried setUserTypeCellRenderer() and still no results.

Message was edited by: Mark Finnern

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Feb 07, 2005 at 04:59 AM

    Hi Aviad,

    You can do this in two ways. Populate the value of all columns in Table Model.

    <u>I Way</u>: Set the column type as Link in TableView Model.

    <hbj:tableView  id="myTableView"
                    model= "myTableViewBean.model"
                    design = "ALTERNATING"
                    headerVisible = "true"
                    footerVisible = "true"
                    fillUpEmptyRows = "true"
                    selectionMode = "MULTISELECT"
                    navigationMode = "BYLINE"
                    headerText = "<h3>tableView</h3>"
                    visibleFirstRow = "1"
                    visibleRowCount = "4"
                    onNavigate="onNavigate" >
    <%
                                 
    myTableView.setColumnType(TableColumnType.LINK,column no);
     %>
      </hbj:tableView>

    <u>II Way</u> Set the column type as TableColumnType.USER and write the cell renderer.

    <%
                                 
    myTableView.setColumnType(TableColumnType.USER,column no);        
    myTableView.setUserTypeCellRenderer(new TableViewCellRenderer()); %>
    
    

    In Cell Renderer "TableViewCellRenderer.java"

    import com.sapportals.htmlb.*;
    import com.sapportals.htmlb.rendering.IPageContext;
    import com.sapportals.htmlb.table.ICellRenderer;
    import com.sapportals.htmlb.table.TableView;
    public class TableViewCellRenderer implements ICellRenderer {
       
        public void renderCell(int row, int column, TableView tableView, IPageContext rendererContext) {
    
            if (column == 1) {
    
             Link mylink = new Link();
             String linkText = tableView.getValueAt(row,  
                               column).toString();
             mylink.addText(linkText);
               
         // Set the renderer
                ddlb.render(rendererContext);
            } 
        }
    }
    
    

    Hope this helps.

    Regards,

    Praveen

    PS. Dont foget to award points if it is useful/solved

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Aviad,

      When you create a question, please leave the "Mark this topic as a question" radio button selected.

      This indicates, that you are asking a question that you want to give points for good answers.

      If you just want to post a general comment, then deselect it. Answers to these kind of questions can't get points.

      I have changed it for you in this thread. So now you can give your points.

      All the best, Mark.

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.