oncomplete does not work

UI Components for JSF
apostle
Posts: 10
Joined: 03 Mar 2012, 10:56

27 Aug 2012, 23:30

The oncomplete code is not run. I see an error in firebug instead that states the following:

SyntaxError: JSON.parse: unexpected non-whitespace character after JSON data
Image

My code is as follows:
JSF page

Code: Select all

    <h:form id="reminder_dialog_form">

        <p:dialog modal="true" id="password_reminder_dialog" widgetVar="passwordReminderDialog"
                  resizable="false" message="" header="#{msg['password.reminder']}"
                  showEffect="fade" hideEffect="explode" draggable="false">

            <div class="reminder">
                <h:panelGroup id="rem">
                    <div style="min-height: 30px">
                        <p:messages globalOnly="true" autoUpdate="true" redisplay="false" />
                    </div>
                    <div class="clr"></div>
                    <h4><h:outputText value="#{msg['password.reminder.message']}"/> </h4>
                    <p:inputText value="#{passwordReminderController.email}" id="reminder_email"/>

                    <div class="clr"></div>
                    <p:message for="reminder_email" display="text" />

                    <div class="clr"></div>

                    <p:commandButton type="submit" value="#{msg['send']}"
                                     process="@this, reminder_email"
                                     action="#{passwordReminderController.remind}"
                                     onclick="statusDialog.show()"
                                     update="rem, :login_form:growl"
                                     oncomplete="statusDialog.hide();if (args.closeDialog) {passwordReminderDialog.hide();}"
                            />
                </h:panelGroup>
            </div>
        </p:dialog>

    </h:form>
backend bean

Code: Select all

    public void remind() {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        User user;
        try {
            user = userService.getUserByEmail(email);
        } catch (ValidationException e) {
            for (ApplicationMessage applicationMessage : e.getMessages()) {
                facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, applicationMessage.getMessage(), ""));
            }
            return;
        } catch (EntityException e) {
            for (ApplicationMessage applicationMessage : e.getMessages()) {
                facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, getLocalizedMessage(applicationMessage.getMessage()), ""));
            }
            return;
        }
        mailService.send(getLocalizedMessage("password.reminder.message.subject")
                , getLocalizedMessage("password.reminder.message.text"
                , new Object[]{user.getPassword()})
                , email);
        facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, getLocalizedMessage("password.reminder.confirmation.message"), ""));
        RequestContext.getCurrentInstance().addCallbackParam("closeDialog", true);
    }
Lately this code worked perfectly. Is it my fault or there is a problem in current snapshot? Thanks

UPDATE:

I tried previaous version of the primefaces jar (see extraction from manifest below) and the code works perfectly with it.

Code: Select all

Bundle-Version: 3.4.0.SNAPSHOT
Bnd-LastModified: 1343899236122 (Tue Aug 14 10:35:31 2012)
Application server: Glassfish 4.1.1
JSF implementation: Mojarra 2.2.12
PrimeFaces: 5.3

SimonSezz
Posts: 18
Joined: 02 Mar 2011, 13:47
Location: Germany

03 Sep 2012, 12:51

Just switched from 3.4RC1 to 3.4 FINAL and encountered the same defect!

Shall we open a ticket?
Using:
Glassfish Application Server V3.1.2
Primefaces Library 3.4RC1 / 3.4 FINAL
Sun Mojarra 2.1.1

apostle
Posts: 10
Joined: 03 Mar 2012, 10:56

03 Sep 2012, 13:29

Hey. I guess...
I did not even think of it because unfortunately I recieved no confirmation from insiders and others who are using the framework that the problem exists. You are the first who declare the same problem.
On the other hand as I put the version that works in my local project repo, before your post I had no idea if the error still persists in the latest version of Primefaces.
I hope developers will make a comment about it here now.
Application server: Glassfish 4.1.1
JSF implementation: Mojarra 2.2.12
PrimeFaces: 5.3

ayslan
Posts: 7
Joined: 27 Apr 2011, 15:05

03 Sep 2012, 14:04

I have this problem when I try to update a component with a lazy data model.
The xml response has a "extension" duplicated.

Example, a lazydatamodel with 2 objects the response is like:

Code: Select all

<extension ln="primefaces" type="args">{"totalRecords":2}</extension>
<extension ln="primefaces" type="args">{"totalRecords":2}</extension>
When primefaces try to get response and parse JSON data, I get this same error. JSON.parse: unexpected non-whitespace character after JSON data.

SimonSezz
Posts: 18
Joined: 02 Mar 2011, 13:47
Location: Germany

03 Sep 2012, 15:05

Ok, I can verify that there is a duplicate String-Object passed to the JSON.parse() method.

I'm using the oncomplete attribute inside a <p:menueitem> nested in a <p:tabMenu> like this:

Code: Select all

<p:tabMenu activeIndex="0" >  
	<p:menuitem value="MenItm1" url="/MenItm1.xhtml"/>  
	<p:menuitem value="MenItm2" action="#{loginBean.addCallback()}" oncomplete="handleLoginRequest(xhr, status, args)" >
		<f:setPropertyActionListener target="#{loginBean.target}" value="/secure/MenItm2.xhtml" />
	</p:menuitem>  
	<p:menuitem value="MenItm3" action="#{loginBean.addCallback()}" oncomplete="handleLoginRequest(xhr, status, args)" >
		<f:setPropertyActionListener target="#{loginBean.target}" value="/secure/MenItm3.xhtml" />
	</p:menuitem>  
</p:tabMenu>
The object passed to the JSON.parse() method looks like this in my case:

Code: Select all

"{"site":"/appName/secure/MenItm1.xhtml","isLoggedIn":false}{"site":"/appName/secure/MenItm1.xhtml","isLoggedIn":false}"
I've already filed a bug: Issue 4592
Using:
Glassfish Application Server V3.1.2
Primefaces Library 3.4RC1 / 3.4 FINAL
Sun Mojarra 2.1.1

cagatay.civici
Prime
Posts: 18264
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

03 Sep 2012, 15:31

I can see only one object at;

Code: Select all

<extension ln="primefaces" type="args">{"loggedIn":true}</extension>
http://www.primefaces.org/showcase-labs ... gLogin.jsf

Also it works fine,

Also paginator sample works with one copy of object;

Code: Select all

<extension ln="primefaces" type="args">{"totalRecords":11}</extension>
We had no test failures on this. What do I miss?

SimonSezz
Posts: 18
Joined: 02 Mar 2011, 13:47
Location: Germany

03 Sep 2012, 17:20

Ok, its official: I'm totally stunned!

After I've undeployed/redeployed my app including a clean server restart and some other fancy stuff to clean all leftovers it seems that the error is gone :shock: :evil:

I cannot even guess what caused the problems earlier becuase I assumed that JavaScript errors happen on client side and all browsers were restarted and cleaned before.

@apostle
@ayslan
Could you please verify the above suggestion (TOTAL clean redeploy and restart including browser) and post the result!?


If this schould really be the solution I apologize for causing so much trouble!

Have Fun!
Using:
Glassfish Application Server V3.1.2
Primefaces Library 3.4RC1 / 3.4 FINAL
Sun Mojarra 2.1.1

apostle
Posts: 10
Joined: 03 Mar 2012, 10:56

03 Sep 2012, 17:30

I did total clean several times before posting my message including deleting all temporary and cache files in the application server and also removing browser cache. The application was able to work properly only with the older library.
I'll be able to try this again tomorrow. Anyway thanks for the notification.
Application server: Glassfish 4.1.1
JSF implementation: Mojarra 2.2.12
PrimeFaces: 5.3

ayslan
Posts: 7
Joined: 27 Apr 2011, 15:05

03 Sep 2012, 20:36

I've found my problem. It's because my project (EAR) has primefaces dependency and WAR too.
EAR was with primefaces duplicated. War -> WEB-INF/lib, EAR -> /lib.
Somehow entered the life cycle 2 times and duplicated the "extension ln="primefaces"" in lazy datatable.

cagatay.civici
Prime
Posts: 18264
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

03 Sep 2012, 21:30

That explains it.

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

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