Tribune

Home » Liferay Portal » English » 3. Development

Vista Combinata Vista Piatta Vista ad Albero
Discussioni [ Precedente | Successivo ]
toggle
Mohammad Haji Rajab Ali
serveResource()
7 maggio 2012 22.06
Risposta

Mohammad Haji Rajab Ali

Punteggio: New Member

Messaggi: 7

Data di Iscrizione: 9 settembre 2011

Messaggi recenti

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.
Hitesh Methani
RE: serveResource()
7 maggio 2012 22.46
Risposta

Hitesh Methani

Punteggio: Regular Member

Messaggi: 171

Data di Iscrizione: 24 giugno 2010

Messaggi recenti

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
Ravi Kumar Gupta
RE: serveResource()
7 maggio 2012 23.28
Risposta

Ravi Kumar Gupta

Punteggio: Liferay Legend

Messaggi: 1303

Data di Iscrizione: 23 giugno 2009

Messaggi recenti

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
sheela mk
RE: serveResource()
28 giugno 2012 4.48
Risposta

sheela mk

Punteggio: Regular Member

Messaggi: 111

Data di Iscrizione: 16 febbraio 2012

Messaggi recenti

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...
Priyanka Dhingra
RE: serveResource()
28 giugno 2012 5.17
Risposta

Priyanka Dhingra

Punteggio: Liferay Master

Messaggi: 501

Data di Iscrizione: 19 dicembre 2011

Messaggi recenti

Hi sheela,
1resourceResponse.setContentType("application/json");
2        resourceResponse.setCharacterEncoding("UTF-8");
3        resourceResponse.getWriter().write(jsonFeed.toString());

you can use this.
and you can put your data like
1JSONObject jsonFeed = JSONFactoryUtil.createJSONObject();
2jsonFeed.put("data", keyValues);
sheela mk
RE: serveResource()
28 giugno 2012 21.12
Risposta

sheela mk

Punteggio: Regular Member

Messaggi: 111

Data di Iscrizione: 16 febbraio 2012

Messaggi recenti

Then how to go next .jsp page..from serveResource()

Like in processAction()..we use actionResponse.setRenderParameter("jspPage","/result.jsp");emoticon
Hussain Shaikh
RE: serveResource()
28 giugno 2012 23.59
Risposta

Hussain Shaikh

Punteggio: Junior Member

Messaggi: 36

Data di Iscrizione: 6 giugno 2012

Messaggi recenti

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
Ranen Das
RE: serveResource()
15 novembre 2012 12.21
Risposta

Ranen Das

Punteggio: Regular Member

Messaggi: 137

Data di Iscrizione: 6 aprile 2011

Messaggi recenti

1
2$.post(url,{msg:"my masage"},function(data){
3
4});


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
RE: serveResource()
15 novembre 2012 12.34
Risposta

David H Nebinger

Community Moderator

Punteggio: Liferay Legend

Messaggi: 11056

Data di Iscrizione: 1 settembre 2006

Messaggi recenti

$ 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.
Vishal Panchal
RE: serveResource()
15 novembre 2012 21.06
Risposta

Vishal Panchal

Punteggio: Expert

Messaggi: 280

Data di Iscrizione: 20 maggio 2012

Messaggi recenti

David 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
RE: serveResource()
19 dicembre 2012 21.36
Risposta

sangeeth k

Punteggio: Regular Member

Messaggi: 114

Data di Iscrizione: 22 aprile 2012

Messaggi recenti

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

 1
 2<portlet:resourceURL var="fetchJsp">
 3
 4    <portlet:param name="fetchJsp" value="/html/vital/single.jsp" />
 5
 6</portlet:resourceURL>
 7
 8[b]IN action file:[/b]
 9
10    public void serveResource(ResourceRequest resourceRequest,
11            ResourceResponse resourceResponse) throws IOException,
12            PortletException {
13         String jspPage = resourceRequest.getParameter("fetchJsp");
14            System.out.println("jspPage==>"+jspPage);
15            if (jspPage != null) {
16
17                include(jspPage, resourceRequest, resourceResponse, PortletRequest.RESOURCE_PHASE);
18               
19               
20            }
21            else {
22                super.serveResource(resourceRequest, resourceResponse);
23            }       
24       
25    }
26In jsp page:
27
28
29<div class="result"></div>
30 
31   
32<script>
33   
34    function ajaxcallTofetchpage()
35    {
36       
37       $.ajax({
38           type: "GET",
39           url: "<%= fetchJsp %>",
40         
41           success: function(msg){
42            //   alert(msg);
43               $('.result').html(msg);
44           }
45         });
46    }
47</script>