简体   繁体   English

在Liferay Portlet中实施编辑

[英]Implement Edit in liferay portlet

I'm developing a liferay portlet. 我正在开发liferay portlet。 Here is my code in jsp file: 这是我在jsp文件中的代码:

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

When user clicks on Edit url, I want to send the selected row items to the portlet class. 当用户单击“编辑URL”时,我想将选定的行项目发送到Portlet类。 But I don't know how to do that. 但是我不知道该怎么做。 How can I do that? 我怎样才能做到这一点?

By your comment it seems you need help in constructing URLs. 通过您的评论,您似乎在构造URL方面需要帮助。

So, you can construct the URL inside the for loop like: 因此,您可以像下面这样在for循环中构造URL:

If you want to use these details to do some database operations like update or insert 如果您想使用这些详细信息来执行一些数据库操作,例如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>

Or if you want to render (or show) some page depending on these fields then use Render URL, like this: 或者,如果您想根据这些字段来渲染(或显示)某些页面,请使用“渲染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>

Also it would help if you can refer some concepts regarding portletURLs and how to use them. 如果您可以参考一些有关portletURL及其使用方法的概念,也会有所帮助。 There are good tutorials available and also Portlets in Action is a good book regarding almost all the concepts of portlet development in one place. 有可用的优秀教程,《 Portlets in Action是一本关于Portlet开发中几乎所有概念的好书。

Hope this helps. 希望这可以帮助。

Prakash K answer it's really good! Prakash K回答,这真的很好! Just adding one thing that can be useful. 只需添加可能有用的一件事。 When you create a portlet action url, you can specifiy a name attribute like this 创建portlet操作URL时,可以指定这样的name属性

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

So that in your portlet class you can call your method like this: 因此,在您的portlet类中,您可以像这样调用您的方法:

Liferay 6.x Liferay 6.x

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

Liferay 5.2 Liferay 5.2

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

This way you can write cleaner and more readble code. 这样,您可以编写更简洁,更易读的代码。 :) :)

Cheers 干杯

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM