-
Notifications
You must be signed in to change notification settings - Fork 746
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2de2c4a
commit 68e4563
Showing
23 changed files
with
1,896 additions
and
1,968 deletions.
There are no files selected for viewing
28 changes: 0 additions & 28 deletions
28
src/main/java/org/primefaces/component/api/AutoUpdatable.java
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
src/main/java/org/primefaces/component/autoupdate/AutoUpdateListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* Copyright 2009-2017 PrimeTek. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.primefaces.component.autoupdate; | ||
|
||
import java.util.ArrayList; | ||
import javax.faces.component.UIComponent; | ||
import javax.faces.context.FacesContext; | ||
import javax.faces.event.AbortProcessingException; | ||
import javax.faces.event.ComponentSystemEvent; | ||
import javax.faces.event.ComponentSystemEventListener; | ||
|
||
/** | ||
* Registers components to auto update | ||
*/ | ||
public class AutoUpdateListener implements ComponentSystemEventListener { | ||
|
||
private static final String COMPONENTS = AutoUpdateListener.class.getName() + ".COMPONENTS"; | ||
|
||
@Override | ||
public void processEvent(ComponentSystemEvent cse) throws AbortProcessingException { | ||
FacesContext context = FacesContext.getCurrentInstance(); | ||
String clientId = ((UIComponent) cse.getSource()).getClientId(context); | ||
|
||
ArrayList<String> clientIds = getOrCreateAutoUpdateComponentClientIds(context); | ||
if (!clientIds.contains(clientId)) { | ||
clientIds.add(clientId); | ||
} | ||
} | ||
|
||
public static ArrayList<String> getOrCreateAutoUpdateComponentClientIds(FacesContext context) { | ||
ArrayList<String> clientIds = getAutoUpdateComponentClientIds(context); | ||
if (clientIds == null) { | ||
clientIds = new ArrayList<String>(); | ||
context.getViewRoot().getAttributes().put(COMPONENTS, clientIds); | ||
} | ||
return clientIds; | ||
} | ||
|
||
public static ArrayList<String> getAutoUpdateComponentClientIds(FacesContext context) { | ||
return (ArrayList<String>) context.getViewRoot().getAttributes().get(COMPONENTS); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
src/main/java/org/primefaces/component/autoupdate/AutoUpdateTagHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* Copyright 2009-2017 PrimeTek. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.primefaces.component.autoupdate; | ||
|
||
import java.io.IOException; | ||
import javax.el.ELException; | ||
import javax.faces.FacesException; | ||
import javax.faces.component.UIComponent; | ||
import javax.faces.event.PostAddToViewEvent; | ||
import javax.faces.event.PreRenderComponentEvent; | ||
import javax.faces.view.facelets.FaceletContext; | ||
import javax.faces.view.facelets.FaceletException; | ||
import javax.faces.view.facelets.TagConfig; | ||
import javax.faces.view.facelets.TagHandler; | ||
|
||
public class AutoUpdateTagHandler extends TagHandler { | ||
|
||
private static final AutoUpdateListener LISTENER = new AutoUpdateListener(); | ||
|
||
public AutoUpdateTagHandler(TagConfig tagConfig) { | ||
super(tagConfig); | ||
} | ||
|
||
@Override | ||
public void apply(FaceletContext faceletContext, UIComponent parent) throws IOException, FacesException, FaceletException, ELException { | ||
// PostAddToViewEvent should work for stateless views | ||
// but fails for MyFaces ViewPooling | ||
// and sometimes on postbacks as PostAddToViewEvent should actually ony be called once | ||
parent.subscribeToEvent(PostAddToViewEvent.class, LISTENER); | ||
|
||
// PreRenderComponentEvent should work for normal cases and MyFaces ViewPooling | ||
// but likely fails for stateless view as we save the clientIds in the viewRoot | ||
parent.subscribeToEvent(PreRenderComponentEvent.class, LISTENER); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 0 additions & 85 deletions
85
src/main/java/org/primefaces/util/AutoUpdateComponentListener.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.