1

我的liferay 自定义portlet 中有一个html 表。我想在单击该特定列时提供编辑功能我知道 liferay-ui:search-container 提供了这样的功能,但是我为此使用了我的 html 表和一些 jquery ..所以在该特定列的悬停时我有一个编辑图标,我希望单击该编辑图标时,我将重定向到编辑页面。但我想要的是如何获取该行的编辑图标的主键被选中..?

我有以下 jquery 用于图标显示并重定向到编辑页面

 <script>
                    $(document).ready(function() {     
                        $(".editable").hover(function(){
                            $(this).append("<i class='splashy-pencil_right'></i>")
                        }, function(){
                            $(this).children("i").remove();
                        });                        
                        $(".editable").click(function(){
                            $.colorbox({
                                initialHeight: '0',
                                initialWidth: '0',
                                href: "#confirm_dialog",
                                inline: true,
                                opacity: '0.3',
                                onComplete: function(){
                                    $('.confirm_yes').click(function(e){
                                        e.preventDefault();
                                        window.location.href = "<%=editURL.toString() %> ";
                                        $.colorbox.close();
                                    });
                                    $('.confirm_no').click(function(e){
                                        e.preventDefault();
                                        $.colorbox.close(); 
                                    });
                                }
                            });
                        });
                        //* show all elements & remove preloader                        
                        setTimeout('$("html").removeClass("js")',1000);
                    });
                </script>

以下是我要重定向的 portletaction url

<portlet:actionURL name="editRestaurant" var="editURL">
       <portlet:param name="key" value="<%=restId%>" />
       </portlet:actionURL>

以下代码是我的视野类,其中将主键值(restID)作为隐藏字段。

      <form action="<%=editURL.toString() %>" method="post">                       
                            <table class="table table-bordered table-striped" id="dt_gal_res">
                                <thead>
                                    <tr>
                                        <th class="table_checkbox"><input type="checkbox" name="select_rows" class="select_rows" data-tableid="dt_gal_rest" /></th>                                        
                                        <th>Name</th>
                                        <th>Contact Person</th>
                                        <th>Website</th>
                                        <th>Emenu</th>                                        
                                        <th>Status</th>
                                    </tr>
                                </thead>





        <% 
     List<restaurant> rest_listOBJ= restaurantLocalServiceUtil.getAllAvailableRestaurant();

for(int i=0;i<(rest_listOBJ.size());i++)
{

restaurant temprest=rest_listOBJ.get(i);

%>
     <tbody>
                                        <tr>
                                            <td><input type="checkbox" name="row_sel" class="row_sel" /></td>                                        
                                            <td style="visibility: hidden;"><input type="text" name="primerykey" value="<%= temprest.getPrimaryKey()%>"></td>
                                            <td class="editable"><%=temprest.getName() %></td>
                                            <td><%=temprest.getContactno() %></td>
                                            <td><%=temprest.getWebsite() %></td>
                                            <td><%=temprest.getNoofemenuagent() %></td>
                                            <td><a href="#" class="pop_over" data-content="Ad Displayed on </br> <b>Restaurant</b> : ABC" data-original-title="( Ad name )" data-placement="left">Pending</a></td>                                        
                                        </tr>                                    
                                   </tbody>

那么如何将此单击的行或列值传输到 edit_restaurant.jsp 页面?

4

1 回答 1

2

创建一个链接并添加 id 作为参数

<% PortletURL link = RenderResponse.createRenderURL();
link.setParameter("paramName", "paramValue");  
link.setParameter("jspPage", "/page.jsp"); %>  

使用链接:
<a href="<%= link.toString() %>">LinkText</a>

在 jsp 上,您可以使用 mvc 方式使用此参数:

ParamUtil.getString(ActionRequest, "paramName");

于 2012-10-22T15:09:11.663 回答