1
votes

I have one html table in my custom portlet of liferay. i want to give edit functionality on click of that particular collumn i know that liferay-ui:search-container provides functionality like this but am using my html table and some jquery for this..so on hover of that particular collumn i have one edit icon and i want that on click of that edit icon i will redirect to edit page.but what i jus want is that how can i get primary key of that row's edit icon is selected..??

i have following jquery for icon displays and redirect to edit page

 <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>

following is my portletaction url on which i want to redirect

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

and following code is of my field of view classes in which am taking primary key value(restID) as a hidden field.

      <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>

so how can i transfer this clicked row or collumn value to the edit_restaurant.jsp page?

1

1 Answers

2
votes

Create a link and add the id as a parameter

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

Use the link:
<a href="<%= link.toString() %>">LinkText</a>

On the jsp you can use this parameter the mvc way using:

ParamUtil.getString(ActionRequest, "paramName");