cancel
Showing results for 
Search instead for 
Did you mean: 

How can i get the current site name in java automatically

mrinal3199
Champ in-the-making
Champ in-the-making
Hi,

  I want to get the site name in my java webscript from whichever site this webscrit has been called without passing any parameter. How to get it solved. Have any one done this before. Please help me out in it.


Thanks,
Mrinal
5 REPLIES 5

fstnboy
Champ on-the-rise
Champ on-the-rise
Hi Mrinal,

In order to know in which site you are, or even to know that you are in a site, you need to pass some kind of parameter to get the webscript in context. This parameter could be the nodeRef of the node you are looking for example.

Then in java, you'll need to inject the siteService to your webscript's bean definition and make use of it, as you can see in the link below it has useful methods like getSite or findSite.

http://dev.alfresco.com/resource/docs/java/repository/org/alfresco/service/cmr/site/SiteService.html

Hope this helps

mrinal3199
Champ in-the-making
Champ in-the-making
Thanks for the reply. Actually i am developing a search utility which should return me the noderefs of the contents found frm that site only from which it has been called. So, i need to have that site name in my lucene query. I don't have any noderef with me except that of site root node. I have gone through these functions but there they expect an input of either site name or their noderef which i don't want to pass. I want that autmatically. Do you have any solutin for that?

Thanks,
Mrinal

mrinal3199
Champ in-the-making
Champ in-the-making
Thanks for the reply. Actually i am developing a custom search utility which will return the results of that site only frm which it has been triggered. So, i need to get this site name autmatically so that i can use that in my lucene query. I have gone through these functions. They all are expecting an input either site name or their noderef which i don't want to pass as a parameter. Do you have any solutin for that.

Thanks,
Mrinal  

mrinal3199
Champ in-the-making
Champ in-the-making
Thanks for the reply. I am developing a custom search utility which will return the results of contents from that site only from which it has been triggered. So, i need to get this site name autmatically so that i can use that in my lucene query. I have gone through these site service functions. They all are expecting an input either site name or their noderef which i don't want to pass as a parameter. Do you have any solution for that. I am able to get the current site name in javascript. So, there must be some solution to get the same from java also. Please reply soon.

Thanks,
Mrinal

rjohnson
Star Contributor
Star Contributor
If you are in the site (i.e. on the site dashboard or anywhere in the document library). This is the default behaviour of the standard search.

In the standard search the ftl that renders the page gives the site name to the search javascript (see search.js).