Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Nagiy reddyy Yedulay
How can i get the image gallery select button in JSP Page.
April 2, 2009 9:56 PM
Answer

Nagiy reddyy Yedulay

Rank: Junior Member

Posts: 96

Join Date: December 3, 2008

Recent Posts

Hai. i got a requirement like i need to show a portlet.Content of Portlet will be

1). Text field with select button.

2).When click on select button it has to show the images in the image gallery.

3).once i click the any one of the image,image pathe has to store on the text box.

How can achieve the above content in JSP portlet.

if any body has the any idea,please let me know.

your ideas are greatly appreciated.


Thanks
Nagireddy Y
Rahul Parashar
RE: How can i get the image gallery select button in JSP Page.
April 21, 2011 2:28 AM
Answer

Rahul Parashar

Rank: New Member

Posts: 7

Join Date: March 21, 2011

Recent Posts

Well thats how i did it.. looking to improve on it..

view.jsp

//On load its shows the default blank image
<img id="displayimage" src="/image/image_gallery?uuid=4115bc88-1dcb-44fa-a60e-4170c835f4df&groupId=18&t=1303323974453"/><br/>
<a href="#" onclick="openWindow();" >Choose an Image</a>

// On click of the link you just have to open the image gallery, i cudnt find a better way so i have to hard code the entire image gallery url
function openWindow()
{

win = window.open("http://localhost:8080/group/control_panel/manage?p_p_id=15&p_p_lifecycle=0&p_p_state=pop_up&p_p_mode=view&doAsGroupId=18&refererPlid=10146&_15_struts_action=%2fjournal%2fselect_image_gallery&_15_groupId=18","mywindow","scroll=1,status=1,menubar=1,resizable=1,width=750,height=850");

}

If you check the code in select_image_gallery.jsp, when you choose a image from image gallery, it calls the opener selectImageGallery() method and passes the image url to it.. So i just created this method in my view.jsp (the opener in my case)..

// Had to hard code the namespace, dint find any other way
function _15_selectImageGallery(url) {

document.getElementById('displayimage').src = url;
document.getElementById('image').value = url;
alert(document.getElementById('image').value);
}

I have url to the input hidden field, you can very well use a input text field and give this url value to it..

Hope this helps..
Andy Harb
RE: How can i get the image gallery select button in JSP Page.
March 12, 2012 7:59 AM
Answer

Andy Harb

Rank: Junior Member

Posts: 66

Join Date: October 22, 2009

Recent Posts

Thanks Rahul,

This is a great way to handle this. The only thing you may want to add is a

1        if(win != null)
2            win.close();


Into the _15_selectImageGalary(url) function. That way after they select an image it closes the window.


One question i have is what permission does a user have in order to select an image? I tried giving the user view into the Image Gallery and a few other things but for some reason if they are not admins they get a "You do not have the required permissions to access this application" message when the window popups up.

Any pointers would be greatly appreciated.

Thanks
Andy
liferay liferay
RE: How can i get the image gallery select button in JSP Page.
July 4, 2012 1:11 AM
Answer

liferay liferay

Rank: New Member

Posts: 3

Join Date: July 4, 2012

Recent Posts

Is it possible at Liferay 6.1 GA? How can I do that?

Thxs
Nishikant sapkal
RE: How can i get the image gallery select button in JSP Page.
July 4, 2012 3:01 AM
Answer

Nishikant sapkal

Rank: Junior Member

Posts: 76

Join Date: February 15, 2010

Recent Posts

liferay liferay:
Is it possible at Liferay 6.1 GA? How can I do that?

Thxs


Yes you can easily do that using LR 6 as well...
Just check the following code which is similar to what LR is using for selecting images.

function openImageSelector(imgId,imgSrc) {

var test='<portlet:renderURL windowState="<%= LiferayWindowState.POP_UP.toString() %>"><portlet:param name="jspPage" value="/select_image.jsp" /><portlet:param name="imageSrc" value='imageSource' /><portlet:param name="imageId" value='imgId'/></portlet:renderURL>';

var imageWindow = window.open(test, 'structure', 'directories=no,height=640,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=680');
imageWindow.focus();
}

now select_image.jsp is the jsp page which will load all images from image gallery you can copy the jsp from image gallery as well.
liferay liferay
RE: How can i get the image gallery select button in JSP Page.
July 4, 2012 11:58 PM
Answer

liferay liferay

Rank: New Member

Posts: 3

Join Date: July 4, 2012

Recent Posts

easily? It's a joke, ok.

select_image.jsp, imgId, imgSrc? Thanks for help me, but I want to open a image (document and media at LR 6.1) gallery selector, check one and get the url or id or something similar.

In LR 6.0 was easily, I only used a url (/group/control_panel/manage?p_p_id=15...) and a one javascript method. Are there any url to open this gallery selector like in LR 6.0?

Thanks
liferay liferay
RE: How can i get the image gallery select button in JSP Page.
July 5, 2012 2:54 AM
Answer

liferay liferay

Rank: New Member

Posts: 3

Join Date: July 4, 2012

Recent Posts

Ok, for LR 6.1 the code is this:

function openWindow()
{
win = window.open("<%=themeDisplay.getPathContext()%>/group/control_panel/manage?p_p_id=15&p_p_lifecycle=0&p_p_state=pop_up&p_p_mode=view&doAsGroupId=<%=idGroup%>&refererPlid=10711&_15_struts_action=%2fjournal%2fselect_document_library&_15_groupId=<%=idGroup%>","mywindow","scroll=1,status=1,menubar=1,resizable=1,width=750,height=850");
}

function _15_selectDocumentLibrary(url, hash, name, version)
{
document.getElementById('displayimage').src = url;
document.getElementById('image').value = url;
}
Jitendra Rajput
RE: How can i get the image gallery select button in JSP Page.
July 13, 2012 11:23 AM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 858

Join Date: January 7, 2011

Recent Posts

liferay liferay:
Ok, for LR 6.1 the code is this:


If i am not wrong then your code will display both Documents and Images in popup ?
How can you display only images from document and media ?
Sachin Aware
RE: How can i get the image gallery select button in JSP Page.
July 20, 2012 9:42 AM
Answer

Sachin Aware

Rank: New Member

Posts: 23

Join Date: July 19, 2012

Recent Posts

Jitendra Rajput:
liferay liferay:
Ok, for LR 6.1 the code is this:


If i am not wrong then your code will display both Documents and Images in popup ?
How can you display only images from document and media ?


To display images from image gallery use select_image_gallery instead of select_document_library.


onclick=" _15_imageGalleryInput = 'url';
_15_imageGalleryInputImage = 'img';
_15_imageGalleryType = 'stroller';
_15_imageGalleryMethod = '';
var imageGalleryWindow = window.open(
'<%=themeDisplay.getPathContext()%>/group/control_panel/manage?p_p_id=15&amp;p_p_lifecycle=0&amp;p_p_state=pop_up&amp;p_p_mode=view&amp;_15_struts_action=%2Fjournal%2Fselect_image_gallery&amp;_15_groupId=livegroupid', 'imageGallery', 'directories=no,height=640,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no,width=680');
void('');
imageGalleryWindow.focus();"

Please replace livegroupid with your group id.


I hope this will help you.

Thanks & Regards,
Sachin Aware
Robert Lee
RE: How can i get the image gallery select button in JSP Page.
April 29, 2013 3:25 PM
Answer

Robert Lee

Rank: New Member

Posts: 1

Join Date: April 29, 2013

Recent Posts

liferay liferay:


function _15_selectDocumentLibrary(url, hash, name, version)
{
document.getElementById('displayimage').src = url;
document.getElementById('image').value = url;
}


Is there more information available somewhere on using _15_selectDocumentLibrary?
How did you know are available parameters? and what is inside the hash?

Thanks!