Foren

Struts2-Jquery localization

Seyed Mohammad Hosein Jamali, geändert vor 12 Jahren.

Struts2-Jquery localization

Junior Member Beiträge: 77 Beitrittsdatum: 13.12.09 Neueste Beiträge
Hello
I am trying to make a Struts2 portlet in liferay 6.0.4 that using Struts2-Jquery plugin. I have a form like this :


	<s:form method="POST" id="signup-form">		
		<s:textfield name="name" key="name" required="true" value="%{name}" />
					
		<s:textfield name="family" key="family" required="true" value="%{family}" />
		
		<s:textfield name="email" key="email" required="true" value="%{email}" />
	
		<s:url id="submitAction" value="/signup-namespace/signup-forms.action"> 	
		              <s:param name="request_locale">ar_SA</s:param>
		</s:url>
		 							 			
		<sj:submit href="%{submitAction}" key="submit" indicator="indicator" button="true" buttonIcon="ui-icon-refresh" />
       </s:form>



But when the form is submitted values of name , family and email are null !! if i remove <s:param name="request_locale">ar_SA</s:param> form is submitted properly and i can access values of name , family and email but locale of my portlet changes to english again !

Can anyone help me to solve this problem ?

Thanks in advance
S.M.H.Jamali
thumbnail
Riccardo Ferrari, geändert vor 12 Jahren.

RE: Struts2-Jquery localization

Regular Member Beiträge: 139 Beitrittsdatum: 13.11.10 Neueste Beiträge
Not sure I can help you. Seems that your button is invoking the s:url ignoring the form. (not performing a POST submit)
You can try to define an s:action (with locale parameters), set it as form action and finally have your button to submit the form.

Which strtus2 and struts2-jquery plugin are you using?
How did you integrate them within liferay?

I've tried jquery plugin some while ago without success because of the jquery version on my Liferay 5.2 installation. Does it works out of the box on Liferay 6??

Thanks
Seyed Mohammad Hosein Jamali, geändert vor 12 Jahren.

RE: Struts2-Jquery localization

Junior Member Beiträge: 77 Beitrittsdatum: 13.12.09 Neueste Beiträge

Which strtus2 and struts2-jquery plugin are you using?
How did you integrate them within liferay?

I've tried jquery plugin some while ago without success because of the jquery version on my Liferay 5.2 installation. Does it works out of the box on Liferay 6??


Hi ,
Version of struts2 is 2.2.3.1 and for struts2-jquery plugin im using struts2-jquery-plugin-3.1.1.jar .
I make a portlet by Liferay IDE (MVC Portlet) and then copy jar files of struts2 and struts2-jquery-plugin in portlet structure so that struts2 jar file can find its requirements. so far It works properly but there is some issues with portlet request/response. Im searching for a way to get current user in the portlet but i have no progress . emoticon

a simple portlet available here :
http://www.robisoft.com/downloads/sample-struts-2-portlet/

Thanks
thumbnail
Riccardo Ferrari, geändert vor 12 Jahren.

RE: Struts2-Jquery localization

Regular Member Beiträge: 139 Beitrittsdatum: 13.11.10 Neueste Beiträge
Currently i'm using Struts2 with most of my portlets. I had problems using jQuery plugin on liferay 5.2 because of the jquery version that liferay provided. (Didn't investigate how to add another jquery library ...)
Are you tellimg me that jquery plugin qorks out-of-the-box on liferay 6? Where did you put the <sj:head /> tag?

About getting the user:
Your action should implements the PortletRequestAware interface. This let you write the setPortletRequest(....) method that allow to populate a PortletRequest object.
Here you can:
-get the user this way:
http://www.liferay.com/community/forums/-/message_boards/message/258377
-get ThemeDisplay that is much more useful:

ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

Seyed Mohammad Hosein Jamali, geändert vor 12 Jahren.

RE: Struts2-Jquery localization

Junior Member Beiträge: 77 Beitrittsdatum: 13.12.09 Neueste Beiträge
Riccardo Ferrari:
Currently i'm using Struts2 with most of my portlets. I had problems using jQuery plugin on liferay 5.2 because of the jquery version that liferay provided. (Didn't investigate how to add another jquery library ...)
Are you tellimg me that jquery plugin qorks out-of-the-box on liferay 6? Where did you put the <sj:head /> tag?

About getting the user:
Your action should implements the PortletRequestAware interface. This let you write the setPortletRequest(....) method that allow to populate a PortletRequest object.
Here you can:
-get the user this way:
http://www.liferay.com/community/forums/-/message_boards/message/258377
-get ThemeDisplay that is much more useful:

ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(WebKeys.THEME_DISPLAY);



I put <sj:head /> in the head of page these are 3 first line of my view.jsp page :


&lt;%@ taglib prefix="s" uri="/struts-tags"%&gt;
&lt;%@ taglib prefix="sj" uri="/struts-jquery-tags"%&gt;
<sj:head jqueryui="true" />

in the jar files of struts2-jquery plugin there is a file named head.ftl that has addresses of resources jquery need to run. you can copy all files under template folder that is exist in the plugin jar files in "portal-web/docroot/html/struts" and add this address to head.ftl of struts2-jquery-plugin-3.1.1.jar

I did what you mentioned above but sometimes requestPortlet is null !! emoticon
thumbnail
Riccardo Ferrari, geändert vor 12 Jahren.

RE: Struts2-Jquery localization

Regular Member Beiträge: 139 Beitrittsdatum: 13.11.10 Neueste Beiträge
What about you struts.xml?
Does your struts.xml packages extends the "struts-portlet-default"?


	<package name="sample" extends="struts-portlet-default" namespace="/sample">
		...actions mapping stuff...
	</package>


It could be related to how you build your actions urls.
Seyed Mohammad Hosein Jamali, geändert vor 12 Jahren.

RE: Struts2-Jquery localization

Junior Member Beiträge: 77 Beitrittsdatum: 13.12.09 Neueste Beiträge
yes my package extends it.
please take a look at here

Thanks