Fórumok
serveResource()
Mohammad Haji Rajab Ali, módosítva 11 év-val korábban
serveResource()
New Member Bejegyzések: 7 Csatlakozás dátuma: 2011.09.10. Legújabb bejegyzések
Hi,
I have wrote a portlet and use serveResource() for convert text to speech,
but i can not send text by document.getElementById().value in value at tag
onClick="location.href = '<portlet:resourceURL><portlet:param name="msg" value="<script languege=javascript>document.getElementById("msg").value;<script/>" /></portlet:resourceURL>'"
please help how can i send textbox.text to value of tag serveResource.
I have wrote a portlet and use serveResource() for convert text to speech,
but i can not send text by document.getElementById().value in value at tag
onClick="location.href = '<portlet:resourceURL><portlet:param name="msg" value="<script languege=javascript>document.getElementById("msg").value;<script/>" /></portlet:resourceURL>'"
please help how can i send textbox.text to value of tag serveResource.
Hitesh Methani, módosítva 11 év-val korábban
RE: serveResource()
Regular Member Bejegyzések: 171 Csatlakozás dátuma: 2010.06.24. Legújabb bejegyzések
Hi Mohammad,
Try putting the required text box in form, and submit the form onClick with resourceURL, this will pass the msg as request param.
Thanks and Regards,
Hitesh Methani
Try putting the required text box in form, and submit the form onClick with resourceURL, this will pass the msg as request param.
Thanks and Regards,
Hitesh Methani
Ravi Kumar Gupta, módosítva 11 év-val korábban
RE: serveResource()
Liferay Legend Bejegyzések: 1302 Csatlakozás dátuma: 2009.06.24. Legújabb bejegyzések
Mohammad, What you are trying is incorrect. You are trying to pass a javascript value to java before it is generated. Instead, call a javascript function on click. Construct the url(without the msg param). You should be using ajax for calling serveresource() method. So, send that msg param with Ajax parameters. like this..
$.post(url,{msg:"my masage"},function(data){
});
HTH
$.post(url,{msg:"my masage"},function(data){
});
HTH
sheela mk, módosítva 11 év-val korábban
RE: serveResource()
Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
Hai..Pls..Let me know how to dispatch from serveResource() method to jsp Page..
getPortletConfig().getPortletContext().getRequestDispatcher(
response.encodeURL("//view.jsp")).include(request, response);
Whats wrong using above line..I do get view.jsp page content on White Screen..Pls Let me know..Whats wrong...
getPortletConfig().getPortletContext().getRequestDispatcher(
response.encodeURL("//view.jsp")).include(request, response);
Whats wrong using above line..I do get view.jsp page content on White Screen..Pls Let me know..Whats wrong...
Priyanka Dhingra, módosítva 11 év-val korábban
RE: serveResource()
Liferay Master Bejegyzések: 501 Csatlakozás dátuma: 2011.12.20. Legújabb bejegyzések
Hi sheela,
you can use this.
and you can put your data like
resourceResponse.setContentType("application/json");
resourceResponse.setCharacterEncoding("UTF-8");
resourceResponse.getWriter().write(jsonFeed.toString());
you can use this.
and you can put your data like
JSONObject jsonFeed = JSONFactoryUtil.createJSONObject();
jsonFeed.put("data", keyValues);
sheela mk, módosítva 11 év-val korábban
RE: serveResource()
Regular Member Bejegyzések: 111 Csatlakozás dátuma: 2012.02.17. Legújabb bejegyzések
Then how to go next .jsp page..from serveResource()
Like in processAction()..we use actionResponse.setRenderParameter("jspPage","/result.jsp");
Like in processAction()..we use actionResponse.setRenderParameter("jspPage","/result.jsp");
Hussain Shaikh, módosítva 11 év-val korábban
RE: serveResource()
Junior Member Bejegyzések: 44 Csatlakozás dátuma: 2012.06.07. Legújabb bejegyzések
Hi,
You don't go to a different page using serverResource(). It is basically ajax call to refresh a portion of your jsp page.
you create a resource url first, in your jsp page like this
<portlet:resourceURL var="variable1" id="identification1" escapeXml="false" />
write ajax function,
ajax.request({
url:"${variable1}",
param:{
param1:"hi"
},
success:function(response){
alert("hi");
}
in your controller if your portlet is spring mvc
@ResourceMapping(value="identification1")
// your method here
you can open your response in a new window using anchor tag,
<a target="_blank" href="${variable1}"
you don't need to write ajax function in this case.
hope it helps
Thanks
You don't go to a different page using serverResource(). It is basically ajax call to refresh a portion of your jsp page.
you create a resource url first, in your jsp page like this
<portlet:resourceURL var="variable1" id="identification1" escapeXml="false" />
write ajax function,
ajax.request({
url:"${variable1}",
param:{
param1:"hi"
},
success:function(response){
alert("hi");
}
in your controller if your portlet is spring mvc
@ResourceMapping(value="identification1")
// your method here
you can open your response in a new window using anchor tag,
<a target="_blank" href="${variable1}"
you don't need to write ajax function in this case.
hope it helps
Thanks
Ranen Das, módosítva 11 év-val korábban
RE: serveResource()
Regular Member Bejegyzések: 137 Csatlakozás dátuma: 2011.04.06. Legújabb bejegyzések
$.post(url,{msg:"my masage"},function(data){
});
Question to Mr Ravi Kumar Gupta - DOES LIFERAY SUPPORT '$', what I know it does not - one has to use like this 'jQuery.post(url,,)' - can you explain '$' ??
David H Nebinger, módosítva 11 év-val korábban
RE: serveResource()
Liferay Legend Bejegyzések: 14915 Csatlakozás dátuma: 2006.09.02. Legújabb bejegyzések
$ was (is) a shortcut for jQuery, but you should not use the $ as I believe 6.x has it as a shortcut for AUI...
Stay away from the $ as it will just make your life difficult.
Stay away from the $ as it will just make your life difficult.
Vishal Panchal, módosítva 11 év-val korábban
RE: serveResource()
Expert Bejegyzések: 289 Csatlakozás dátuma: 2012.05.20. Legújabb bejegyzésekDavid H Nebinger:
$ was (is) a shortcut for jQuery, but you should not use the $ as I believe 6.x has it as a shortcut for AUI...
Stay away from the $ as it will just make your life difficult.
Hi David,
you are right , some days ago I had a same problem with "$" but after that instead of using "$" I put "jQuery" and it works.!
Thanks&Regards,
Vishal R. Panchal
sangeeth k, módosítva 11 év-val korábban
RE: serveResource()
Regular Member Bejegyzések: 114 Csatlakozás dátuma: 2012.04.22. Legújabb bejegyzések
HI team,
I am facing issue including jsp page using serveResource(),
my scenario I have 3 tabs with images onclick of each tab i am including jsp page..
I am not using liferay tabs....using jquery tabs:
so
I am facing issue including jsp page using serveResource(),
my scenario I have 3 tabs with images onclick of each tab i am including jsp page..
I am not using liferay tabs....using jquery tabs:
so
<portlet:resourceurl var="fetchJsp">
<portlet:param name="fetchJsp" value="/html/vital/single.jsp" />
</portlet:resourceurl>
[b]IN action file:[/b]
public void serveResource(ResourceRequest resourceRequest,
ResourceResponse resourceResponse) throws IOException,
PortletException {
String jspPage = resourceRequest.getParameter("fetchJsp");
System.out.println("jspPage==>"+jspPage);
if (jspPage != null) {
include(jspPage, resourceRequest, resourceResponse, PortletRequest.RESOURCE_PHASE);
}
else {
super.serveResource(resourceRequest, resourceResponse);
}
}
In jsp page:
<div class="result"></div>
<script>
function ajaxcallTofetchpage()
{
$.ajax({
type: "GET",
url: "<%= fetchJsp %>",
success: function(msg){
// alert(msg);
$('.result').html(msg);
}
});
}
</script>