gpt4 book ai didi

grails - Grails Liferay Portlet不调用操作

转载 作者:行者123 更新时间:2023-12-02 14:21:55 26 4
gpt4 key购买 nike

我试图使用Grails 1.2.1和grails-portlets 0.7和grails-portlets-liferay 0.2插件为Grails 1.2.1创建Liferay 5.2.2的简单portlet。

我创建并部署了一个库存portlet(只是更新了标题,描述等...)。它可以正确部署,并且 View 可以正确呈现。但是,当我提交view.gsp中的默认表单时,它永远不会命中actionView函数。

以下是相关的代码位:

SearchPortlet.groovy

class SearchPortlet {

def title = 'Search'
def description = '''
A simple search portlet.
'''
def displayName = 'Search'
def supports = ['text/html':['view', 'edit', 'help']]

// Liferay server specific configurations
def liferay_display_category = 'Category'

def actionView = {
println "In action view"
}

def renderView = {
println "In render view"
//TODO Define render phase. Return the map of the variables bound to the view
['mykey':'myvalue']
}

...
}

view.gsp
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet" %>
<div>
<h1>View Page</h1>
The map returned by renderView is passed in. Value of mykey: ${mykey}
<form action="${portletResponse.createActionURL()}">
<input type="submit" value="Submit"/>
</form>
</div>

每当我查看portlet时,以及按下提交按钮后,tomcat终端都会打印 In render view。它从不打印 In action view语句。

有任何想法吗?

更新

我打开了日志记录功能,这是我在portlet中单击“提交”按钮时看到的内容:
[localhost].[/gportlet]  - servletPath=/Search, pathInfo=/invoke, queryString=null, name=null
[localhost].[/gportlet] - Path Based Include
portlets.GrailsDispatcherPortlet - DispatcherPortlet with name 'Search' received render request
portlets.GrailsDispatcherPortlet - Bound render request context to thread: com.liferay.portlet.RenderRequestImpl@7a158e
portlets.GrailsDispatcherPortlet - Testing handler map [org.codehaus.grails.portlets.GrailsPortletHandlerMapping@1f06283] in DispatcherPortlet with name 'Search'
portlets.GrailsDispatcherPortlet - Testing handler adapter [org.codehaus.grails.portlets.GrailsPortletHandlerAdapter@74f72b]
portlets.GrailsPortletHandlerAdapter - portlet.handleMinimised not set, proceeding with normal render
portlet.SearchPortlet - In render view
portlets.GrailsPortletHandlerAdapter - Couldn't resolve action view /search/null.gsp
portlets.GrailsPortletHandlerAdapter - Trying to render mode view /search/view.gsp
portlets.GrailsDispatcherPortlet - Setting portlet response content type to view-determined type [text/html;charset=ISO-8859-1]
[localhost].[/gportlet] - servletPath=/WEB-INF/servlet/view, pathInfo=null, queryString=null, name=null
[localhost].[/gportlet] - Path Based Include
portlets.GrailsDispatcherPortlet - Cleared thread-bound render request context: com.liferay.portlet.RenderRequestImpl@7a158e
portlets.GrailsDispatcherPortlet - Successfully completed request

该日志代码段的第四行显示Bound render request ...,我不明白,因为Portlet中表单中的操作是操作URL。我以为那应该是一个行动要求。

最佳答案

我也有同样的问题,让它正常工作将非常好。

更新

我在表单中添加了method="post",它的工作原理很像:)

关于grails - Grails Liferay Portlet不调用操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2254139/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com