Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OutputPanel: deferred mode defect #7953

Closed
StevenHachel opened this issue Oct 13, 2021 · 45 comments
Closed

OutputPanel: deferred mode defect #7953

StevenHachel opened this issue Oct 13, 2021 · 45 comments
Assignees
Labels
third-party Issue is tracked in 3rd party library workaround A workaround has been provided

Comments

@StevenHachel
Copy link

StevenHachel commented Oct 13, 2021

<p:outputPanel deferred="true">
dosent work under PrimeFaces 8.0.x.

This is very very bad for my migrated Company software.
All pages cant loaded in lazy mode. Only refresh this Application with F5 shows a working outpurPanel.

The loading of new components or the refreshing of components with complex database queries no longer works via command buttons, navigation bars etc. in lazylaoding mode via the output panel.
This is really very, very critical for us.

Pleace fix this bug. Pleace! :-(

We cannot switch to Primefaces 10/11 so quickly because we are too small a team. This problem did not exist under Primefaces 4/5/6/7.

primefaces-test--outputpanel-bug-8.0.zip

Profile: mojarra22

@StevenHachel StevenHachel added the 🐞 defect Bug...Something isn't working label Oct 13, 2021
@tandraschko tandraschko added the elite This issue is related to an Elite release label Oct 13, 2021
@tandraschko
Copy link
Member

tandraschko commented Oct 13, 2021

i will close this issue here as this is not for elite-only bugs and we cant even fix it
therefore i ping PrimeTek, if they may fix it: @mertsincan

If you need this fix, you can also use PrimeFaces PRO to sponsor the fix for the next elite release

@StevenHachel
Copy link
Author

StevenHachel commented Oct 13, 2021

Who do I have to write to so that this is reported as a bug and possibly fixed?
In the migration instructions "7->8" it was not mentioned that the component "outpuPanel" is defect or deprecated.

For me, the elite account makes no sense if components suddenly no longer work and I have to become a pro user in order to be able to use a functioning Primefaces. That sounds like a rip-off and that wasn't what Primefaces used to be.

@tandraschko
Copy link
Member

tandraschko commented Oct 13, 2021

maybe it would be make sense to create a private issue tracker for elite like for PRO
but thats all up to PrimeTek, i can just ping @mertsincan

@melloware
Copy link
Member

So I am confused @StevenHachel Did it work on 8.0 and broke in 8.0.X elite or is it broken in 8.0 Community too?

@StevenHachel
Copy link
Author

StevenHachel commented Oct 13, 2021

@melloware
Since Primefaces 8.0. I migrated from 7.0.23 to 8.0.13.

The Class OutputPanelRenderer has new methode:

    protected boolean isDeferredNecessary(FacesContext context, OutputPanel panel) {
        return !context.getPartialViewContext().isAjaxRequest() && panel.isDeferred();
    }

In version 5/6/7, only panel.isDeferred() was checked. I copied the compiled class OutputPanelRenderer from version 7 to version 8 and then everything works as usual again.

The construct was extended by the method:
!context.getPartialViewContext().isAjaxRequest()

That is what causes the problem. What do I have to configure and how so that it works as usual under PF 8?

@melloware
Copy link
Member

melloware commented Oct 13, 2021

Oh its easy just Extend OutputPanelRenderer and override that protected method.

Then in you faces-config.xml just plug the renderer in.

    <render-kit>
        <renderer>
            <component-family>org.primefaces.component</component-family>
            <renderer-type>org.primefaces.component.OutputPanelRenderer</renderer-type>
            <renderer-class>com.yourcompany.MyOutputPanelRenderer</renderer-class>
        </renderer>
    </render-kit>

@melloware melloware added the workaround A workaround has been provided label Oct 13, 2021
@StevenHachel
Copy link
Author

@melloware
You didn't rebuild the renderer like this for nothing. Could there be any downside to overwriting it?
What is the reason that you expanded the exam?

In my example you can see that it no longer works due to your conversion.

You're the experts, I'm just the one looking at the code. 😁

@melloware
Copy link
Member

Not sure why it was changed but in 11.0.0 its fixed and even improved.

See: #7867

Even better feature: #7712

@StevenHachel
Copy link
Author

@melloware
big THX for your help. am enthusiastic about your support. :)

Steven

@StevenHachel
Copy link
Author

StevenHachel commented Jan 12, 2022

Hey,
under JavaEE8 and Weblogic 14.1.1.0.0 does not work this workaround anymore. :-(

When this workaround is active, then breaking the <p: ajaxStatus /> oncomplete state. :-( This is then simply no longer triggered.
This brings with it the problem that the <p:outputPanel deferred="true"/> again does not handle lazy laoding.
By the way. A bit annoying unfortunately.

@jepsar
Copy link
Member

jepsar commented Jan 12, 2022

@StevenHachel You are still talking about 8.0.13?

@StevenHachel
Copy link
Author

@jepsar Primefaces 8.0.14 :-)

@StevenHachel
Copy link
Author

Hello,
I know I'm only a Primefaces Elite user and not eligible for support, but is there a workaround for JavaEE8 to make it work again?

Some pages take a really, really long time to load without this option and it's annoying that it doesn't work anymore.

Please excuse my question.
Steven

  • JavaEE 8.0
  • JSF 2.3.9 (org.glassfish -javax.faces)
  • Primefaces 8.0.19
  • omnifaces 2.7.18
  • Payara 5

@jepsar
Copy link
Member

jepsar commented Jul 20, 2022

Either get PRO support (https://github.com/primefaces/primefaces#community--elite--pro) or upgrade to PF 12 (RC was released yesterday).

@StevenHachel
Copy link
Author

StevenHachel commented Jul 26, 2022

Defect since PF 8! Primefaces was the top 1 framework for us at the time because it had this lazy loading feature. Now you just removed it without officially mentioning it.

Have now spent two days migrating our business project to Primefaces 12. Had to find out that it is still defective.

If only I had tested first instead of relying on the statement. :(

Attached is the test project with PF 12.0.0.RC. It still does not work.
primefaces-test--outputpanel-bug-12.0.zip

mojarra22
mojarra23

@tandraschko tandraschko reopened this Jul 26, 2022
@tandraschko tandraschko added this to the 12.0.0-RC3 milestone Jul 26, 2022
@melloware
Copy link
Member

@StevenHachel looks like Thomas is investigating but I don't understand why overriding the Renderer to put the code back the way it was in 7 stopped working for you?

@tandraschko
Copy link
Member

@melloware i would check it this week, if you have more time, you can also do it now :)

@melloware
Copy link
Member

I will look into it!

@melloware
Copy link
Member

melloware commented Jul 26, 2022

@StevenHachel here is the PrimeFaces 12 way of doing it and its much better user experience that people are familiar with from Facebook and GitHub known as a "Skeleton".

pf-7953.zip

Try my reproducer and see what you think...
It is also what is demonstrated on the showcase: https://www.primefaces.org/showcase/ui/panel/outputPanel.xhtml?jfwid=f8e62

@melloware melloware changed the title outputPanel deffred mode defect in PF8 (Primefaces Elite 8.0.13) OutputPanel: deferred mode defect Jul 26, 2022
@StevenHachel
Copy link
Author

@StevenHachel looks like Thomas is investigating but I don't understand why overriding the Renderer to put the code back the way it was in 7 stopped working for you?

If I'd know that.
It doesn't seem to work anymore under JavaEE 8 and JSF 2.3.x and Payara 5 / Weblogic 14.
When I overwrite the renderer, the Ajax status "Complete" no longer runs as soon as actions are taken in the business app (as far as I can tell).
Only a refresh (F5) of the page then only helps. But that's not a solution for me.

You have to find out why that is. You are the specialists and I have trusted in your skills for 15 years! :-)

@melloware
Copy link
Member

@StevenHachel I have an even easier solution for you. Just add loaded="false" to your output panel and it puts it back the way it use to work in PF7.

<p:outputPanel deferred="true" loaded="false">

and if you want to set that property on ALL output panels in your app simply follow these instructions to turn it on globally: https://primefaces.github.io/primefaces/11_0_0/#/core/globalattributes?id=global-attributes

@StevenHachel
Copy link
Author

@StevenHachel I have an even easier solution for you. Just add loaded="false" to your output panel and it puts it back the way it use to work in PF7.

<p:outputPanel deferred="true" loaded="false">

and if you want to set that property on ALL output panels in your app simply follow these instructions to turn it on globally: https://primefaces.github.io/primefaces/11_0_0/#/core/globalattributes?id=global-attributes

I will test it tomorrow. Thanks for your support. :-)
Let me know if it was successful for me.

Steven

@StevenHachel
Copy link
Author

@StevenHachel I have an even easier solution for you. Just add loaded="false" to your output panel and it puts it back the way it use to work in PF7.

<p:outputPanel deferred="true" loaded="false">

and if you want to set that property on ALL output panels in your app simply follow these instructions to turn it on globally: https://primefaces.github.io/primefaces/11_0_0/#/core/globalattributes?id=global-attributes

I will test it tomorrow. Thanks for your support. :-) Let me know if it was successful for me.

Steven

I see that it works fine in the simple test application.
In our business application, however, this leads to problems. Within the outputPanel component, if the flag is activated (loaded="false"), Javascript errors are triggered, which only makes the app usable again after a refresh (F5).

We use the outputPanel component mainly for datatables (editable, etc.) and critical areas that take a long time to load, which also use many clientRemote functions to perform certain actions.

It doesn't really work anymore. I keep thinking about going back to PF 7 again. Always going to the latest version is always a small risk for us, since Primefaces does not always work perfectly in the new versions. All the changes have to be tested somehow and you always change a lot in the new PF versions. :)

But before that I test the "Skeleton" (only PF 12?) option again.

Steven

@jepsar
Copy link
Member

jepsar commented Jul 27, 2022

Always going to the latest version is always a small risk for us, since Primefaces does not always work perfectly in the new versions. All the changes have to be tested somehow and you always change a lot in the new PF versions. :)

Please do keep your application up to date. There are many fixes between versions of which some might be security fixes. If any issues arise, please report them (better for everyone). There is a large and growing number of integration tests which should prevent regression. If there is a certain feature which is critical for you, and there is no integration test for that yet, you can always open a pull request to add such a test.

And please read https://github.com/primefaces/primefaces#community--elite--pro

@melloware
Copy link
Member

melloware commented Jul 27, 2022

@StevenHachel echoing what @jepsar said but also I just tried the MyOutputRenderer trick and it works on Mojarra and MyFaces and I tried it in Wildfly, Tomee, and straight Jetty and its working fine.

See this reproducer: pf-7953-renderer.zip

So I think you need to investigate to make sure your faces-config.xml is actually being picked up properly to override the renderer.

@melloware melloware added needs investigation Issue needs more investigation to find out if its a real issue and removed 🐞 defect Bug...Something isn't working elite This issue is related to an Elite release labels Jul 27, 2022
@StevenHachel
Copy link
Author

StevenHachel commented Jul 28, 2022

@melloware I'll take another look at why it's not working for me. As I said, it worked under JavaEE6, but since the switch to JavaEE8 and Payara 5, the Ajax status is no longer set to "complete" due to this change. I'm trying to write an example.

Thanks for the help!

Steven

Edit: I now see why the Ajax "complete" event is not being fired.
Using the custom renderer always triggers a JavaScript error.
"Uncaught TypeError: v is undefined"
I now have to examine myself as to why this is so. I will report.

@tandraschko
Copy link
Member

please just provide a sample, what is not working for you within a primefaces-test project
we cant helper otherwise.

@melloware
Copy link
Member

@StevenHachel agreed with Thomas it works just fine in my PF TEst reproducer and makes it work just like PF7 used to so you have something else going on with your custom code.

@StevenHachel
Copy link
Author

StevenHachel commented Jul 29, 2022

hey everyone,
i got it reproduced! :-)

Attached is a small sample project, which is similar to our business project in terms of navigation. It consists of many decoupled modules that are deployed via Maven as required.

I somehow tried to recreate it roughly and didn't find any errors until in the last step I simply changed the javax.faces version to 2.3.9 under the "Mojarra22" profile, since under JavaEE8 (and Payara 5) JSF 2.3.x is used.

Then the error appears that paralyzes the entire JavaScript ecosystem.

Please just click on the "stammdaten" link and call up the console with F12 (Firefox).
Please make sure it runs on Mojarra 2.3.9.

If "MyOutputPanelRenderer" is deactivated, this error does not appear, or with javax.faces version 2.2.x.

Steven

pf-7953-renderer_mojarra_2.3.9.zip

@melloware
Copy link
Member

melloware commented Jul 29, 2022

Still can't reproduce:
pf-7953-2.zip

mvn clean jetty:run -Pmyfaces22 WORKS

mvn clean jetty:run -Pmyfaces23 WORKS

mvn clean jetty:run -Pmojarra22 WORKS

mvn clean jetty:run -Pmojarra23 WORKS

mvn clean jetty:run -Pmojarra239 WORKS

Works with all versions of MyFaces and Mojarra tested including both 2.3.9 that you report as not working and 2.3.18 which is latest Mojarra 2.3.X. Tested on Firefox and Chrome.

@StevenHachel
Copy link
Author

StevenHachel commented Jul 29, 2022

So the context is started with Mojara version 2.3.9 (javax.faces, NOT jakarta.faces) and no error can be seen in the console when you click on "stammdaten"? Possibly change the size of the console (Firefox) once so that the error also appears there. So only open it after you click on it.
You can already see that the status dialog at the bottom right is no longer executed as soon as you click somewhere else.
I can also take screenshots of it.

@melloware
Copy link
Member

melloware commented Jul 29, 2022

Is this the error you see in Firefox:
image
???

If so as I suspected its your code. Your menu is generating this...

<a id="leftSiteMenuForm:j_id_w:j_id_x:j_id_y_1_3" href="#" class="ui-commandlink ui-widget" aria-label="" onclick="return false;;PrimeFaces.ab({s:&quot;leftSiteMenuForm:j_id_w:j_id_x:j_id_y_1_3&quot;,f:&quot;leftSiteMenuForm&quot;,u:&quot;leftSiteMenuForm:leftSiteMenuPanel merlinMainContent&quot;,ps:true});return false;" style="margin-left: 12px !important;                                        font-size: 12px !important;                                        font-weight: bold; color: #2699d1; font-size: 11px !important">stammdaten</a>

Basically onclick="return false;;PrimeFaces.ab... Firefox is saying you are NOT allowed to do anything after returning false. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Stmt_after_return

So its your code I don't think it has anything to do with Mojarra or the MyOutputRenderer etc.

it looks like its related to this stuff:

onclick="#{cc.attrs.controller.isCurrentApplicationModuleComponentDesciption(itemTool) ? 'return false;' : ''}"

@StevenHachel
Copy link
Author

StevenHachel commented Jul 29, 2022

If so as I suspected its your code. Your menu is generating this...

<a id="leftSiteMenuForm:j_id_w:j_id_x:j_id_y_1_3" href="#" class="ui-commandlink ui-widget" aria-label="" onclick="return false;;PrimeFaces.ab({s:&quot;leftSiteMenuForm:j_id_w:j_id_x:j_id_y_1_3&quot;,f:&quot;leftSiteMenuForm&quot;,u:&quot;leftSiteMenuForm:leftSiteMenuPanel merlinMainContent&quot;,ps:true});return false;" style="margin-left: 12px !important;                                        font-size: 12px !important;                                        font-weight: bold; color: #2699d1; font-size: 11px !important">stammdaten</a>

Basically onclick="return false;;PrimeFaces.ab... Firefox is saying you are NOT allowed to do anything after returning false. See: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Errors/Stmt_after_return

So its your code I don't think it has anything to do with Mojarra or the MyOutputRenderer etc.

it looks like its related to this stuff:

onclick="#{cc.attrs.controller.isCurrentApplicationModuleComponentDesciption(itemTool) ? 'return false;' : ''}"

Thx for Info! :-) I will test it without the "return flag".

@StevenHachel
Copy link
Author

StevenHachel commented Jul 29, 2022

Is this the error you see in Firefox: image ???

No, this is the error in javax.faces 2.3.x
grafik


and IntelliJ Startuplog:

INFORMATION: Mojarra 2.3.9 ( 20190401-1936 77894020e94a338c9701619b7ef6e9871c5a9079) für Kontext '/primefaces-test' wird initialisiert.
Jul 29, 2022 6:43:19 PM com.sun.faces.spi.InjectionProviderFactory createInstance
INFORMATION: JSF1048: PostConstruct/PreDestroy-Annotationen vorhanden.  Verwaltete Bean-Methoden, die mit diesen Annotationen markiert sind, lassen die entsprechenden Annotationen verarbeiten.
Jul 29, 2022 6:43:19 PM org.primefaces.webapp.PostConstructApplicationEventListener processEvent
INFORMATION: Running on PrimeFaces 12.0.0-RC2
Jul 29, 2022 6:43:19 PM org.primefaces.extensions.application.PostConstructApplicationEventListener processEvent
INFORMATION: Running on PrimeFaces Extensions 12.0.0-RC2
[INFO] Started o.e.j.m.p.JettyWebAppContext@655523dd{/primefaces-test,[file:///J:/ProjectFolderIntelliJ/primefaces-test/pf-7953-renderer_mojarra_2.3.9/src/main/webapp/, jar:file:///J:/.m2/repository/org/primefaces/extensions/primefaces-extensions/12.0.0-RC2/primefaces-extensions-12.0.0-RC2.jar!/META-INF/resources, jar:file:///J:/.m2/repository/org/glassfish/javax.faces/2.3.9/javax.faces-2.3.9.jar!/META-INF/resources, jar:file:///J:/.m2/repository/org/primefaces/primefaces/12.0.0-RC2/primefaces-12.0.0-RC2.jar!/META-INF/resources],AVAILABLE}{file:///J:/ProjectFolderIntelliJ/primefaces-test/pf-7953-renderer_mojarra_2.3.9/src/main/webapp/}
[INFO] Started ServerConnector@3dc39412{HTTP/1.1, (http/1.1)}{0.0.0.0:8080}
[INFO] Started @6022ms
[INFO] Started Jetty Server

@melloware
Copy link
Member

weird I get literally NO errors in my console. I can't reproduce your issue at all. Your code is working fine for me.

image

@melloware
Copy link
Member

OK I just got it. In Firefox i have to resize the browser to trigger the error!

@melloware
Copy link
Member

OK this turned out to be a PFE Layout bug I opened it here: primefaces-extensions/primefaces-extensions#902

I attached a fixed reproducer so you can see it working!
pf-7953-fixed.zip

I added a Monkeypatch in your HussCommon.js file.

@melloware melloware removed this from the 12.0.0-RC3 milestone Jul 29, 2022
@melloware melloware added third-party Issue is tracked in 3rd party library and removed needs investigation Issue needs more investigation to find out if its a real issue labels Jul 29, 2022
@StevenHachel
Copy link
Author

OK this turned out to be a PFE Layout bug I opened it here: primefaces-extensions/primefaces-extensions#902

I attached a fixed reproducer so you can see it working! pf-7953-fixed.zip

I added a Monkeypatch in your HussCommon.js file.

Thanks for the patch, but it doesn't really solve the problem. There is no longer an exception, but all other JavaScript functions such as
<p:ajaxStatus onstart="showStatusDialog()" oncomplete="hideStatusDialog()"/>
are simply not triggered anymore. It was the same without the patch, just without an exception in the console.

<p:ajaxStatus... is just an example. I also registered websockets via JavaScript and so on, which then simply stop working and also the internal Primefaces JavaScript.

But thanks for the trouble, I'll have to see if I can get Payara to work with Mojarra 2.2.x, which will probably be difficult.

Anyway, I'm glad you realized there was a problem. :)

Steven

@StevenHachel
Copy link
Author

Hello,

I've added another example without Primefaces Extensions layout and also added a debugger DIV, for example to monitor the AjaxStatus.

As you can see, after clicking on the "stammdaten" link, no more AjaxStatus is triggered. If I skip the click on the "stammdaten", you can see that it works perfectly.

If I switch to Mojarra version 2.2.x (within the POM under profile mojarra22 (javax.faces)) or remove the CustomRenderer in the faces-config, the OutputPanel no longer works, but there is no problem with the AjaxStatus, for example.

There is definitely still a problem in interaction with Mojarra 2.3.x (javax.faces).

pf-7953-renderer_mojarra_2.3.9_problem_without_extension_layout.zip

@tandraschko
Copy link
Member

tandraschko commented Aug 2, 2022

i think your problem is the same as: #8838
if you check the AJAX request from the outputPanel, the viewState is missing, which leads to a bad state.
this fixes your problem:

            <p:outputPanel deferred="true" loaded="false">
                <p:ajax event="load" async="false" />

loaded=false was discussed above and you can remove your overwritten renderer.

we may switch to async=false to avoid such problems, see: #9055

@StevenHachel
Copy link
Author

StevenHachel commented Aug 2, 2022

<p:ajax event="load" async="false" />

It works! With and without Layout! Many many thx!
Thank you all for your help!

Steven

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
third-party Issue is tracked in 3rd party library workaround A workaround has been provided
Projects
None yet
Development

No branches or pull requests

5 participants