is there any way to open lightbox programatically?
setting visible parameter doesnt work for me
got it working, too much hassle again but working heres stuff if anybody is interested, bit mess but it opens up lightbox with picture on page load in certain situations, you can do it programatically
LightBox lb = (LightBox) FacesContext.getCurrentInstance().getViewRoot().findComponent("galForm:lb");
System.out.println(lb);
lb.setVisible(true);
LightBox lb = (LightBox) FacesContext.getCurrentInstance().getViewRoot().findComponent("galForm:lb");
System.out.println(lb);
lb.setVisible(true);
Code: Select all
<h:head>
<script type="text/javascript">
window.onload = function() {
loadMain();
}
</script>
</h:head>
Code: Select all
<p:outputPanel rendered="#{galBean.goItem!=null}">
<p:lightBox id="lb" widgetVar="lbWidget" iframe="true" width="80%" height="80%">
<h:outputLink
value="#{galBean.goItem.url}"
title="#{galBean.goItem.display}">
</h:outputLink>
</p:lightBox>
</p:outputPanel>
Code: Select all
<!-- gotta be here for registered load method to work worrected with ajax update -->
<h:form>
<p:remoteCommand name="loadMain" actionListener="#{authBean.loadMain}"
update="dialogForm:messages #{authBean.updateOnLoad}" />
</h:form>
Code: Select all
public void loadMain(ActionEvent event) {
if (getLoadMsg()!=null) {
FacesContext.getCurrentInstance().addMessage( null, getLoadMsg() );
setLoadMsg( null );
}
//invoke reged methods on load...
for (Method method:methods) {
try {
MethodUtils.invokeExactMethod(method.getObj(), method.getName(),new Object[]{},new Class[]{} );
} catch (NoSuchMethodException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
}
methods.clear();
updateOnLoad = "";
}
Code: Select all
public void setUpdateOnLoad() {
String res = "";
for (Method method:methods)
res += res.isEmpty() ? method.getUpdate() : " " + method.getUpdate();
updateOnLoad = res;
}
public String getUpdateOnLoad() {
System.out.println("upOnLoad "+updateOnLoad);
return updateOnLoad;
}
public void regMethodOnLoad(Object obj, String name, String update) {
methods.add(new Method(obj,name,update));
setUpdateOnLoad();
}
Code: Select all
public void openLightBox() {
LightBox lb = (LightBox) FacesContext.getCurrentInstance().getViewRoot().findComponent("galForm:lb");
System.out.println(lb);
lb.setVisible(true);
}
public SvnItem getGoItem() {
SvnItem sel = null;
for (SvnItem item: getItems())
if (item.getAutoVisible()) {
sel = item;
break;
}
return sel;
}
public void lbOpen() {
SvnItem sel = getGoItem();
System.out.println("LBOPEN !!! "+sel);
if (sel!=null) {
openLightBox();
}
}
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
- bumble.bee
- Posts: 723
- Joined: 29 Sep 2010, 21:39
- Location: United States
In the meantime you can use the following JavaScript to show a lightbox:
See this site for full list of options:
http://colorpowered.com/colorbox/
Note: I still include a
Code: Select all
onclick="jQuery.colorbox({href:'http://google.com/', iframe: true, width: '80%', height: '80%'}); return false;"
http://colorpowered.com/colorbox/
Note: I still include a
component on the page just so the required css and js are included.<p:lightBox/>
Good news PF 3.1 came out. I would not find this topic , if not looked on the bugfix list (BTW: quite amazing number).
OK so in lightbox we have show and hide. I don`t want to sound ungrateful , but I still cannot reproduce the image showcase.
I stripped it down to the following code:
What happens: When clicking on a small image, background grays out, and a small black backs with dots circling appear. Tries to load but does not work.
The issue is maybe that I have a image-servlet that processes just post and get methods and it fails on lightbox AJAX call. This should not be the case because I was able to link a lightbox in inline mode with imageswitch option before. The best result I achieved, is each image in imageswitch opens different inline lightboxes. Some of my working attempts I discussed here [1] [2].
However I am still unable to get a real slide-show with p:ligjhtbox. Best would be a method "replace", so when clicking on an image in p:carousel or a p:imageswitch your p:commandlink arround your images can display the same lightbox with other images. I have this issue for monthes, so I am patient.
Greets,
Adam
[1] viewtopic.php?f=3&t=16304
[2] viewtopic.php?f=3&t=15322
OK so in lightbox we have show and hide. I don`t want to sound ungrateful , but I still cannot reproduce the image showcase.
I stripped it down to the following code:
Code: Select all
<p:lightBox>
<ui:repeat value="#{bean.imageList}" var="image" varStatus="innerLoop">
<h:outputLink value="/image-servlet-path/#{image.mname}" title="Image Slide Nr. #{innerLoop.index}">
<p:graphicImage value="/image-servlet-path/#{image.sname}"
style="margin:auto;width:#{image.swidth}px;
height:#{image.sheight}px" />
</h:outputLink>
</ui:repeat>
</p:lightBox>
The issue is maybe that I have a image-servlet that processes just post and get methods and it fails on lightbox AJAX call. This should not be the case because I was able to link a lightbox in inline mode with imageswitch option before. The best result I achieved, is each image in imageswitch opens different inline lightboxes. Some of my working attempts I discussed here [1] [2].
However I am still unable to get a real slide-show with p:ligjhtbox. Best would be a method "replace", so when clicking on an image in p:carousel or a p:imageswitch your p:commandlink arround your images can display the same lightbox with other images. I have this issue for monthes, so I am patient.
Greets,
Adam
[1] viewtopic.php?f=3&t=16304
[2] viewtopic.php?f=3&t=15322
Busy applying primefaces patches to my local repo at /dev/null
User error:)
Instead of:
need to use:
(notice the leading "../" )
Now I will hide them, and with bumble.bee`s tip I use $.colorbox.next() and $.colorbox.prev() inside my craousel`s or imageswitch`s next() and prev(). Thus I should get finnally a "full blown" imageswitch-lightbox
EDIT: the colorbox approach would be simplest, but its jquery interfere with PF`s so i probably stich with inline lightbox and put an imageswitch inside.
Greets,
Instead of:
Code: Select all
[...]<h:outputLink value="/image-servlet-path/#{image.mname}" title="Image Slide Nr. #{innerLoop.index}">[...]
Code: Select all
<h:outputLink value="../]image-servlet-path/#{image.mname}" title="Image Slide Nr. #{innerLoop.index}">
Now I will hide them, and with bumble.bee`s tip I use $.colorbox.next() and $.colorbox.prev() inside my craousel`s or imageswitch`s next() and prev(). Thus I should get finnally a "full blown" imageswitch-lightbox
EDIT: the colorbox approach would be simplest, but its jquery interfere with PF`s so i probably stich with inline lightbox and put an imageswitch inside.
Greets,
Last edited by ltune on 01 Feb 2012, 16:08, edited 1 time in total.
Busy applying primefaces patches to my local repo at /dev/null
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
ColorBox is gone if you rely on p:lightBox. 3.1 has a native lightbox.
http://blog.primefaces.org/?p=1635
http://blog.primefaces.org/?p=1635
Yes, thank you, I will stick to this advice.optimus.prime wrote:ColorBox is gone if you rely on p:lightBox. 3.1 has a native lightbox.
http://blog.primefaces.org/?p=1635
Busy applying primefaces patches to my local repo at /dev/null
Hi,
One more issue: when the elements inside an inline lightbox change, on next open there will be some additional broken lightbox above the correct lightbox. You need to refresh all page to get the broken lightbox away. Tested with imageswitch inside inline lightbox on PF 3.1-SNAPSHOT.
Maybe best I really use modal dialog, since they behave similar.
Greets,
One more issue: when the elements inside an inline lightbox change, on next open there will be some additional broken lightbox above the correct lightbox. You need to refresh all page to get the broken lightbox away. Tested with imageswitch inside inline lightbox on PF 3.1-SNAPSHOT.
Maybe best I really use modal dialog, since they behave similar.
Greets,
Busy applying primefaces patches to my local repo at /dev/null
-
- Information
-
Who is online
Users browsing this forum: No registered users and 67 guests