Search Results

Search found 5 results on 1 pages for 'alanobject'.

Page 1/1 | 1 

  • Mixing AJAX requests with Flash scope objects not working

    - by AlanObject
    I have a JSF page that displays a table from an object called TableQuery that supports stateful pagination, sorting, etc. The bean that accesses the object is a RequestScoped object, and it attempts to preserve the TableQuery by storing it the flash map. The accessor method looks like this: public TableQuery<SysLog> getQuery() { if (query != null) return query; Flash flash = FacesContext.getCurrentInstance(). getExternalContext().getFlash(); query = (TableQuery) flash.get("Query"); if (query != null) System.out.println("TableSysLog.getQuery() Got query from flash!"); if (query == null) { query = slc.getNewTableQuery(); System.out.println("TableSysLog.getQuery() Created new query"); } flash.put("Query", query); return query; } The Links to go between pages are implemented with *p:commandLInk*s. I use Primefaces command link in AJAX mode so just the link gets processed when it is clicked. The action listener looks like this: public void doNextPage(ActionEvent evt) { getQuery().doNextPage(); } When it doesn't work I get the error message: WARNING: JSF1095: The response was already committed by the time we tried to set the outgoing cookie for the flash. Any values stored to the flash will not be available on the next request. I found this thread when looking up this problem. When I turned of HTTP chunking as the article suggests, the error message went away but the problem remained. Does anyone know what is going on and how this might be fixed?

    Read the article

  • Getting started with SVG graphics objects in JSF 2.0 pages.

    - by AlanObject
    What I want to do is create web pages with interactive SVG content. I had this working as a Java desktop application using Batik to render my SVG and collect UI events like mouseclick. Now I want to use those SVG graphics files in my JSF (Primefaces) web application in the same way. Trying to get started, I found this didn't work: <h:graphicImage id="gloob" value="images/sprinkverks.svg" alt="Graphic Goes Here"/> I don't mind doing some reading to get up the learning curve. It was just a bit surprising that some google searches didn't turn up anything useful. What I did find suggested that I would have to do this with the f:verbatim tag as if I were hand-coding the HTML. I would then have to add some script to capture the SVG events and feed them back into the AJAX code. If I have to do all that I will, but I was hoping there would be an easier and automated way. So the questions are: How to get the image to render in the first place? How to get the DOM events from the SVG portion of the page back to the backing beans? Much thanks for any pointers.

    Read the article

  • What is PrimeFaces p:editor based on?

    - by AlanObject
    I want to add some client-side functionality to the PrimeFaces p:editor, but for some reason I am not able to uncover what JavaScript client side code they used to build the component. Could anyone point me to that? P.S. two things I want to do is make the component resizable (PrimeFaces doesn't support that) and I want to add shortcut buttons to insert pre-programmed text. Any hints about how this will done will be appreciated.

    Read the article

  • The best JSF coding pattern for editing JPA entities using @RequestScoped only

    - by AlanObject
    I am in a project where I will write a lot of pages like this, so I want to use the most efficient (to write) coding pattern. Background: In the past I have used CODI's @ViewAccessScoped to preserve state between requests, and more recently I have started using flash scoped objects to save state. I can't use JSF @ViewScoped because I use CDI and they don't play well together. So I want to see if I can do this with only @RequestScoped backing beans. The page is designed like this (the p namespace is Primefaces): <f:metadata> <f:viewParam name="ID" value="#{backing.id}" /> </f:metadata> .... <h1>Edit Object Page</h1> <h:form id="formObj" rendered="#{backing.accessOK}"> <p:panelGrid columns="2"> <h:outputLabel value="Field #1:"/> <p:inputText value="#{backing.record.field1}" /> (more input fields) <h:outputLabel value="Action:" /> <h:panelGroup> <p:commandButton value="Save" action="#{backing.save}" /> <p:commandButton value="Cancel" action="backing.cancel" /> </h:panelGroup> </p:panelGrid> <p:messages showDetail="true" showSummary="true" /> </h:form> If the page is requested, the method accessOK() has the ability to keep the h:form from being rendered. Instead, the p:messages is shown with whatever FacesMessage(s) the accessOK() method cares to set. The pattern for the bean backing looks like this: @Named @RequestScoped public class Backing { private long id; private SomeJPAEntity record; private Boolean accessOK; public long getId() { return id; } public void setId(long value) { id = value; } public boolean accessOK() { if (accessOK != null) return accessOK; if (getRecord() == null) { // add a FacesMessage that explains the record // does not exist return accessOK = false; // note single = } // do any other access checks, such as write permissions return accessOK = true; } public SomeJPAEntity getRecord() { if (record != null) return record; if (getId() > 0) record = // get the record from DB else record = new SomeJPAEntity(); return record; } public String execute() { if (!accessOK()) return null; // bad edit // do other integrity checks here. If fail, set FacesMessages // and return null; if (getId() > 0) // merge the record back into the data base else // persist the record } } Here is what goes wrong with this model. When the Save button is clicked, a new instance of Backing is built, and then there are a lot of calls to the getRecord() getter before the setID() setter is called. So the logic in getRecord() breaks because it cannot rely on the id property being valid when it is called. When this was a @ViewAccessScoped (or ViewScoped) backing bean, then both the id and record properties are already set when the form is processed with the commandButton. Alternatively you can save those properties in flash storage but that has its own problems I want to avoid. So is there a way to make this programming model work within the specification?

    Read the article

  • Why can't I have static public fields in my managed beans?

    - by AlanObject
    I just started using the Netbeans 7.1 beta and it is calling out errors of a type which I have never seen before. Specifically: A managed bean with a public field should not declare any scope other than @Dependent. The fields it is complaining about are public static final. I can understand the restriction on non-static fields, but I can't think of a good reason this would not be allowed for a static field. Unfortunately I use a lot of them since I don't like having constants in my code. I note that even though I get the red dot in the margin in the editor, the maven-driven build still works and GlassFish still runs my application the way I would expect. So what is my denoument on this issue? Am I going to have to move my static fields elsewhere or is there another way of handling this?

    Read the article

1