2012-06-27 78 views
1

我正在开发一个liferay portlet。这是我在JSP文件中的代码:Implement在liferay portlet中编辑

<table class="DDGridView"> 
<tr class="td"> 
    <td class="th">Complex Name</td> 
    <td class="th">City</td> 
    <td class="th">Status</td> 
</tr> 
<% 
    Complex complex; 
    for(int i = 0 ; i < complexList.size(); i++) 
    { 
     complex = (Complex)complexList.get(i); 
%> 
     <tr class="td"> 
      <td><%=complex.complexName %></td> 
      <td><%=complex.complexCity %></td> 
      <% 
       if(complex.isActive == 1) 
       { 
      %>    
        <td class="th">Active</td> 
      <% 
       } 
       else 
       { 
      %> 
        <td>Not Active</td> 
      <% 
       } 
      %> 
      <td><a href="<%=prepareEditComplexURL%>">Edit</a></td> 
      <td><a>Delete</a></td> 
     </tr> 
<% 
    } 
%> 
</table> 

当用户点击编辑URL,我要选择的行项发送到portlet类。但我不知道该怎么做。我怎样才能做到这一点?

+0

你能详细说说你是什么意思的“选定的行项目”。你如何准备'prepareEditComplexURL'或者你想帮助准备这个URL本身? –

+0

通过单击编辑执行转到Portlet类中的方法。在该方法中,我需要知道complexName,complexCity和Edit按钮被单击的行的状态。 – Karadous

回答

4

通过您的评论,您似乎需要帮助来构建网址。

所以,你可以构造内的URL for循环,如:

如果你想利用这些信息做一些数据库操作像updateinsert

<portlet:actionURL var="preparedEditComplexURL"> 
    <portlet:param name="complexName" value="<%=complex.complexName %>" /> 
    <portlet:param name="complexCity " value="<%=complex.complexCity %>" /> 
    <portlet:param name="status " value="<%=complex.isActive %>" /> 
</portlet:actionURL> 

或者,如果你想渲染(或显示)一些页面取决于这些字段,然后使用渲染URL,如下所示:

<portlet:renderURL var="preparedEditComplexURL"> 
    <portlet:param name="complexName" value="<%=complex.complexName %>" /> 
    <portlet:param name="complexCity " value="<%=complex.complexCity %>" /> 
    <portlet:param name="status " value="<%=complex.isActive %>" /> 
</portlet:renderURL> 

另外它会hel p如果你可以参考一些有关portletURL的概念以及如何使用它们。有好的教程可用,并且Portlets in Action是关于几乎所有portlet开发概念的好书。

希望这会有所帮助。

1

Prakash K回答非常好!只需添加一件可能有用的东西。 当您创建一个portlet操作URL,你可以指定地址的名称属性,这样

<portlet:actionURL name="preparedEditComplex" var="preparedEditComplexURL"> 
    <portlet:param name="complexName" value="<%=complex.complexName %>" /> 
    <portlet:param name="complexCity " value="<%=complex.complexCity %>" /> 
    <portlet:param name="status " value="<%=complex.isActive %>" /> 
</portlet:actionURL> 

所以,在你的portlet类,你可以打电话给你的方法是这样的:

的Liferay 6.x的

public preparedEditComplex(ActionRequest actionRequest, ActionResponse actionResponse) { 
    //Your implementation 
    ... 
} 

的Liferay 5.2

@ProcessAction(name="preparedEditComplex") 
public preparedEditComplex(ActionRequest actionRequest, ActionResponse actionResponse) { 
    //Your implementation 
    ... 
} 

这样你就可以写一个更清洁d更多可读代码。 :)

干杯