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

CDI: Allow non-component Faces events observeable by CDI #1501

Closed
tandraschko opened this issue Apr 19, 2020 · 9 comments
Closed

CDI: Allow non-component Faces events observeable by CDI #1501

tandraschko opened this issue Apr 19, 2020 · 9 comments
Labels
EE12 mojarra-implemented API issue implemented by Mojarra myfaces-implemented API issue implemented by MyFaces Type: New Feature
Milestone

Comments

@tandraschko
Copy link

tandraschko commented Apr 19, 2020

i general it would be great to catch system events like PostConstructApplicationEvent

See: https://deltaspike.apache.org/documentation/jsf.html#Eventbroadcasting

I currently see following categories and events:

System

         <system-event-class>jakarta.faces.event.ExceptionQueuedEvent</system-event-class>
         <system-event-class>jakarta.faces.event.PostConstructApplicationEvent</system-event-class>
         <system-event-class>jakarta.faces.event.PreDestroyApplicationEvent</system-event-class>

This can be observed by:

public void listen(@Observes PostConstructApplicationEvent event) {...}

View

         <system-event-class>jakarta.faces.event.PreRenderViewEvent</system-event-class>
         <system-event-class>jakarta.faces.event.PostConstructViewMapEvent</system-event-class>
         <system-event-class>jakarta.faces.event.PreDestroyViewMapEvent</system-event-class>

This can be observed by:

public void listen(@Observes PreRenderViewEvent event) {...}

public void listen(@Observes @View("/myview.xhtml") PreRenderViewEvent event) {...}
@arjantijms arjantijms added the 4.0 label Apr 13, 2021
@tandraschko tandraschko changed the title Faces 4.0: Allow system events useable for non-component/renderer classes Allow system events useable for non-component/renderer classes Jun 9, 2022
@tandraschko tandraschko added this to the 4.1 milestone Jun 9, 2022
@tandraschko tandraschko removed the 4.0 label Jun 9, 2022
@tandraschko

This comment was marked as off-topic.

@tandraschko tandraschko modified the milestones: 4.1, 5.0 Feb 25, 2023
@tandraschko tandraschko changed the title Allow system events useable for non-component/renderer classes CDI: Allow system events useable for non-component/renderer classes Jun 11, 2024
@tandraschko tandraschko changed the title CDI: Allow system events useable for non-component/renderer classes CDI: Allow non-component Faces events observeable by CDI Jun 11, 2024
@tandraschko
Copy link
Author

Thats it actually: tandraschko/myfaces@3689580

please review
@arjantijms @pizzi80 @BalusC @melloware

@BalusC
Copy link
Member

BalusC commented Jun 15, 2024

This is great. Let's do it for 5.0.

@tandraschko
Copy link
Author

apache/myfaces@60ae7eb

@tandraschko tandraschko added the myfaces-implemented API issue implemented by MyFaces label Jul 5, 2024
@arjantijms arjantijms added the EE12 label Jan 8, 2025
BalusC added a commit that referenced this issue Feb 2, 2025
BalusC added a commit to eclipse-ee4j/mojarra that referenced this issue Feb 2, 2025
BalusC added a commit to eclipse-ee4j/mojarra that referenced this issue Feb 2, 2025
ComponentSystemEvent as apparently PreRenderViewEvent is an instance
thereof
BalusC added a commit that referenced this issue Feb 2, 2025
BalusC added a commit that referenced this issue Feb 2, 2025
@BalusC
Copy link
Member

BalusC commented Feb 2, 2025

I went a step further and simply adjusted Application#publishEvent() to fire the event via CDI as well. I only deviated from issue title "non-component Faces events" because PreRenderViewEvent is actually a ComponentSystemEvent and apparently we want to fire it.

PR for spec and tck: #2005
PR for Mojarra impl: eclipse-ee4j/mojarra#5550

@tandraschko
Copy link
Author

nice
will now adjust myfaces as well

@tandraschko
Copy link
Author

@BalusC
just one hint
https://github.com/apache/myfaces/blob/main/impl/src/main/java/org/apache/myfaces/cdi/ViewEventBroadcaster.java#L52

if you fire the event for @View, CDI handles automatically the fallback to observers without @View

could you verify, that your solution doesnt invoke a observer without @View 2 times?

@BalusC
Copy link
Member

BalusC commented Feb 18, 2025

That didn't work (in Weld). You can find here the test case https://github.com/jakartaee/faces/pull/2005/files

@tandraschko
Copy link
Author

added a testcase in our code; works at least fine with quarkus and OWB

@tandraschko tandraschko added the mojarra-implemented API issue implemented by Mojarra label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EE12 mojarra-implemented API issue implemented by Mojarra myfaces-implemented API issue implemented by MyFaces Type: New Feature
Projects
None yet
Development

No branches or pull requests

3 participants