Accesing DOM or javascript?

UI Components for JSF
Post Reply
rophiroth
Posts: 2
Joined: 07 Feb 2011, 04:51

07 Feb 2011, 05:09

Hi!

I'm trying to manage the position of a draggable object(component like panel for example) from a bean. I try different way setting the "style" but don't make any visual change even with a web submit... it just work for a "first time instance". I think if I could get some way to access DOM or JS from the bean could do anything I want. Someone know how to do it? or any suggestion to manage the position of a prime component?

Here is my code:
xhtml

Code: Select all

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">
    <h:head>
        <title>Facelet Title</title>
        <p:resources />
    </h:head>
    <h:body>
            <p:commandButton value="msg" update="growl" actionListener="#{Carta.msg}"  />

            <p:panel binding="#{Carta.panel}" id="pnl" style="width: 120px; height: 200px; position:absolute;
                 top:#{Carta.y};
                 left:#{Carta.x}; "
                  header="Draggable Panel">
                <h:outputText value="Y:#{Carta.y} X:#{Carta.x}" />
            </p:panel>
            <p:draggable for="pnl" binding="#{Carta.drag}" />
    </h:body>
</html
Bean

Code: Select all

import javax.faces.application.FacesMessage;
import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;


/**
 *
 * @author Ro
 */
@ManagedBean(name="Carta")
@ApplicationScoped
public class Carta
{
    String x="20px",y="40px";

    public void msg(ActionEvent actionEvent) {
         x="69px";
         y="69px";

         FacesContext context = FacesContext.getCurrentInstance();
         context.addMessage(null, new FacesMessage("move!", "new position"+x+" "+y));
     }
    ..get and sets..
}

The better idea I got was creating a list and statics panel... Then I just have to change the order of the list to "move" the objects. But that is too much "static" and limited.

I'm Using jsf 2.0.2rc and primefaces 2.2. Please help! I was not not able to get good answer from google =/

Best Regard to all!

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 61 guests