我有一些带有一些portlet的liferay门户。 Portlet例如有一些动作:
Private Sub chkBox2_CheckedChanged(sender As Object, e As EventArgs) Handles chkBox2.CheckedChanged
'Find if "Text Here 1" exists. If so, delete it, since we're going to be adding it again.
Dim text = ""
Dim startindex = 0
Dim endindex = 0
For i As Integer = 0 To txtBox.Lines.Length - 1
text = txtBox.Lines(i)
If text.Contains("Text Here 1") = True Then
startindex = txtBox.GetFirstCharIndexFromLine(i)
endindex = text.Length
txtBox.[Select](startindex, endindex)
txtBox.Text = txtBox.Text.Replace(txtBox.SelectedText, String.Empty)
End If
Next
'Find if "Text Here 3" exists. If so, delete it, since we're going to be adding it again.
For i As Integer = 0 To txtBox.Lines.Length - 1
text = txtBox.Lines(i)
If text.Contains("Text Here 3") = True Then
startindex = txtBox.GetFirstCharIndexFromLine(i)
endindex = text.Length
txtBox.[Select](startindex, endindex)
txtBox.Text = txtBox.Text.Replace(txtBox.SelectedText, String.Empty)
End If
Next
'if chkBox2 is checked, then add "Text Here 1"
If chkBox2.Checked = True Then
txtBox.Text = "Text Here 1" & vbNewLine & txtBox.Text & vbNewLine
'Search for "Text Here 1"
Dim Search As String = txtBox.Text
Dim SearchResult As Integer = 0
If Search.Contains("Text Here 1") Then
SearchResult = SearchResult + 1
End If
'Search for "Text Here 2"
If Search.Contains("Text Here 2") Then
SearchResult = SearchResult + 1
End If
Dim lines As List(Of String) = txtBox.Lines.ToList()
Dim index As Integer = lines.FindIndex(Function(line) line.Contains("Text Here 1")) + SearchResult
If index > -1 Then
If chkBoxMisc.Checked = False Then
lines.Insert(index, vbNewLine & "TextBox 3 - Misc Off")
Else
lines.Insert(index, vbNewLine & "TextBox 3 - Misc On")
End If
End If
txtBox.Lines = lines.ToArray()
End If
Me.txtBox.Lines = Me.txtBox.Text.Split(New Char() {ControlChars.Lf}, StringSplitOptions.RemoveEmptyEntries)
End Sub
在liferay中我可以使用此操作,一切正常。但!我有第二个应用程序(普通的spring mvc hibernate等),我需要调用这个动作。 Srsly我不知道该怎么做。谁能帮我?
我用:
创建了路径文件@RenderMapping(params = "action=displayHome")
public String displayHome(final RenderRequest request, final RenderResponse response, final ModelMap map) {
return "home";
}
我有问题,它不起作用。始终将我发送到实际页面 - >不会调用操作:/
答案 0 :(得分:1)
选项1 - 从您可以使用它的页面复制网址并将其粘贴到您的Spring应用中。 下行 - 门户网站中的许多内容都可能发生变化,导致网址更改,您的应用程序将无法再使用。
选项2 - 了解如何构建网址并从Spring应用中生成网址。 下行 - portlet URL复杂且冗长(此处没有足够的空间来详细描述所有选项)
选项3 - 为您的portlet生成Fiendly URL(s)并在Spring应用中使用它。 下行 - 如果将portlet移至其他页面,将停止工作)
选项4 - 不要单独使用portlet,而是使用本地/远程服务+ portlet。将您的逻辑放在本地服务中,在本地通过portlet调用它,并通过远程服务形成其他应用程序(甚至是移动应用程序)
答案 1 :(得分:0)
解决方案: 的liferay-portlet.xml中:
<friendly-url-mapper-class>com.liferay.portal.kernel.portlet.DefaultFriendlyURLMapper</friendly-url-mapper-class>
<friendly-url-mapping>xxx_mapping</friendly-url-mapping>
<friendly-url-routes>config/xxx-friendly-url-routes.xml</friendly-url-routes>
<instanceable>false</instanceable>
资源/配置中的路由:
<routes>
<route>
<pattern>/displayXXXPattern</pattern>
<generated-parameter name="action">displayXXX</generated-parameter>
<implicit-parameter name="p_p_lifecycle">0</implicit-parameter>
<implicit-parameter name="p_p_mode">view</implicit-parameter>
<implicit-parameter name="p_p_state">normal</implicit-parameter>
<implicit-parameter name="p_p_id"xxx_WAR_dekraaquaportlet</implicit-parameter>
</route>
</routes>
重要的 - &GT;当instanceable设置为false时,我们不需要传递实例ID - &gt;在其他情况下,如果我们在p_p_id中没有传递正确的实例ID(什么是add,liferay不显示任何错误或错误),它将无法工作。
在portlet中我们可以关闭:<init-param>
<name>check-auth-token</name>
<value>false</value>
</init-param>
在其他情况下我们需要压制p_p_auth