cancel
Showing results for 
Search instead for 
Did you mean: 

Passing args to webscripts from jsp

shlomi
Champ in-the-making
Champ in-the-making
Hello,

I am trying to figure out how I can call a webscript from a jsp, with specific arguments.

I have replaced the browse.jsp with one of my own, and pointed to it in the navigation xml.

I want to include the doclist control within the view of each space. so in the desired place in the new mybrowse.jsp, I have the line
<r:webScript scriptUrl="wcs/ui/doclist" />

this generates the control, but it always shows me the content of the companyHome.

To change that, I need to pass a parameter (and I succeed if I do it in the browser)
http://alfresco:8080/alfresco/wcs/ui/doclist$&f=0%p=/Company%20Home/shlomi/

I dont know how to pass this parameter from within the jsp. when I tried to put the same url I did in the browser, it ignores it.
Also, I didnt see any special tags like the jsp:include has (such as jspSmiley Tonguearam or anything like that).

Please please, I have a deadline this thursday, and I am loosing my mind over it, tell me if my approach is wrong, or what can I do.

Regards,
Shlomi
9 REPLIES 9

davidc
Star Contributor
Star Contributor
I think you can just pass the arguments in the url…

e.g.  wcs/ui/doclist?arg1=1&arg2=2

shlomi
Champ in-the-making
Champ in-the-making
Hey,
thanks for the reply.

As I said in my post, i did try that, and it didnt work for me. When I tried to print the arg (in the webscript), it threw an exception that the variable is not declared, as opposed to when I ran the same webscript through the browser with that url, and it printed the argument's value, and showed me the correct files..

do you know of any other option, or perhaps what could I have done wrong?

Thanks,
Shlomi

shlomi
Champ in-the-making
Champ in-the-making
Now Iam truly confused..

I tried to change the names of the arguments, and for some it worked, and for some it didnt. now, out of the main blue, it decided to work with the 'p' variable.. (really, I changed nothing but the names of the variable in the sending jsp and reciving ftl)

Anyhow, can you please tell me how do I get the current path (eg: /Company Home/Shlomi/) within the jsp? I tried #{NavigationBean.currentNode.name}, but that gives me just the last name (eg: Shlomi).

I looked up Node in the javadoc (http://dev.alfresco.com/resource/docs/java/web-client/index.html?org/alfresco/web/bean/repository/No...), but I dont see anything helpful..

Thanks

kevinr
Star Contributor
Star Contributor
As Dave said in his reply, you can pass parameters directly on the url to the webscript component, for example:
<r:webScript scriptUrl="/wcs/ui/doclist?p=/Company%20Home/Guest%20Home" />
This works.

shlomi
Champ in-the-making
Champ in-the-making
yes, it seems to work.
I probably did something wrong in the beginning, but it works now. Thanks for both your replies.

Shlomi

faisal
Champ in-the-making
Champ in-the-making
Hi can you please tell me the steps to do this. I am kinda stuck.
What i am trying to do is include the output of a webscript inside a jsp page.
I think this is exactly what you have done.

Any help will be appreciated.. Thanks in advance

shlomi
Champ in-the-making
Champ in-the-making
Hey,
it has been some time since I touched this code, but i believe I did exactly what kevinr said, and just used the r:webscript command…

Have you tried doing that? what does it do?

lamba
Champ on-the-rise
Champ on-the-rise
Hi everybody,

Please, I need to pass the noderef argument of my currentNode and I modified afterward the call of my WS as follows:

       <r:webScript scriptUrl="/wcservice/custom/doclist" context="#{NavigationBean.currentNode.nodeRef}" />

But the problem is that I can't get back this value from the class of my WS  :?:  :!:

I tried this call but that did not work  :!:

        FacesContext context = FacesContext.getCurrentInstance();
        String homeSpaceId = Application.getCurrentUser(context).getHomeSpaceId();
        NodeRef nodeRef = new NodeRef(Repository.getStoreRef(), homeSpaceId);


Thank you for your help.

lamba
Champ on-the-rise
Champ on-the-rise
Solved Smiley Happy

The declaration had to be as follows:

    <r:webScript scriptUrl="/wcservice/custom/doclist?nodeRef={noderef}" context="#{NavigationBean.currentNode.nodeRef}" />

The recovery of this variable from my class is simply by:

        String nodeRefStr = request.getParameter("nodeRef");
   NodeRef nodeRef = new NodeRef(nodeRefStr);

Praise to Allah, the Lord of the Worlds Smiley Happy.