Skip to content

Commit

Permalink
Mojarra 2.3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapster committed May 3, 2024
1 parent 1a03052 commit bbaecd5
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 44 deletions.
2 changes: 1 addition & 1 deletion conf/checkstyle-tests.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<module name="SuppressionSingleFilter">
<property name="checks" value=".*"/>
<property name="files" value="UIDataFacesPatch.java"/>
<property name="files" value="UIDataPatch.java"/>
</module>

<module name="FileTabCharacter"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<module name="SuppressionSingleFilter">
<property name="checks" value=".*"/>
<property name="files" value="UIDataFacesPatch.java"/>
<property name="files" value="UIDataPatch.java"/>
</module>

<module name="FileTabCharacter"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@
import org.primefaces.component.columngroup.ColumnGroup;
import org.primefaces.component.columns.Columns;
import org.primefaces.model.LazyDataModel;
import org.primefaces.component.patch.UIDataFacesPatch;
import org.primefaces.component.patch.UIDataPatch;
import org.primefaces.util.ComponentUtils;
import org.primefaces.util.ELUtils;

/**
* Enhanced version of the JSF UIData.
*/
public class PrimeUIData extends UIDataFacesPatch {
public class PrimeUIData extends UIDataPatch {

private static final Logger LOGGER = Logger.getLogger(PrimeUIData.class.getName());

Expand Down Expand Up @@ -191,7 +191,7 @@ protected void setRowIndexWithoutRowStatePreserved(int rowIndex) {

public void setRowModel(int rowIndex) {
//update rowIndex
getStateHelper().put(UIDataFacesPatch.PropertyKeys.rowIndex, rowIndex);
getStateHelper().put(UIDataPatch.PropertyKeys.rowIndex, rowIndex);
getDataModel().setRowIndex(rowIndex);

//clear datamodel
Expand Down Expand Up @@ -485,7 +485,7 @@ protected List<UIComponent> getIterableChildren() {
}

@Override
protected Boolean isNestedWithinIterator(FacesContext context) {
protected Boolean isNestedWithinIterator() {
if (isNested == null) {
isNested = ComponentUtils.isNestedWithinIterator(this);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,6 @@ protected boolean isCacheableColumns(List<UIColumn> columns) {
// do not cache if nested in iterator component and contains dynamic columns since number of columns may vary per iteration
// see https://github.com/primefaces/primefaces/issues/2154
return getFacesContext().getCurrentPhaseId() == PhaseId.RENDER_RESPONSE
&& (!isNestedWithinIterator(getFacesContext()) || columns.stream().noneMatch(DynamicColumn.class::isInstance));
&& (!isNestedWithinIterator() || columns.stream().noneMatch(DynamicColumn.class::isInstance));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public DataTableHandler(ComponentConfig config) {
super(config);
}

@SuppressWarnings("unchecked")
@Override
protected MetaRuleset createMetaRuleset(Class type) {
MetaRuleset metaRuleset = super.createMetaRuleset(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
// Private class to represent saved state information

/**
* {@link UIDataFacesPatch} is largely a copy of Mojarra 2.3.1's {@code UIData} and few bits from MyFaces
* {@link UIDataPatch} is largely a copy of Mojarra 2.3.9's {@code UIData} and few bits from MyFaces
* The idea is to make a clear distinction between what belongs to the JSF implementation
* and PrimeFaces. The code replicates exactly the code of the original class with a few exceptions:
* <ul>
* <li>All members become protected, so that it's possible for PrimeFaces to override methods if necessary.</li>
* <li>Few methods are either copied or become abstract as they are tightly coupled with Mojarra.</li>
* <li>{@link UIDataFacesPatch#getClientId(FacesContext)} and {@link UIDataFacesPatch#getContainerClientId(FacesContext)} copied from MyFaces (see MYFACES-2744)</li>
* <li>Support of MyFaces view pooling in {@link UIDataFacesPatch#saveState(FacesContext)}</li>
* <li>{@link UIDataPatch#getClientId(FacesContext)} and {@link UIDataPatch#getContainerClientId(FacesContext)} copied from MyFaces (see MYFACES-2744)</li>
* <li>Support of MyFaces view pooling in {@link UIDataPatch#saveState(FacesContext)}</li>
* </ul>
*
* <p><strong class="changed_modified_2_0_rev_a
Expand All @@ -80,9 +80,9 @@
* the <code>setRendererType()</code> method.</p>
*/

public abstract class UIDataFacesPatch extends UIData {
public abstract class UIDataPatch extends UIData {

protected static final String SB_ID = UIDataFacesPatch.class.getName() + "#id";
protected static final String SB_ID = UIDataPatch.class.getName() + "#id";

// ------------------------------------------------------ Instance Variables

Expand Down Expand Up @@ -139,7 +139,6 @@ protected enum PropertyKeys {

protected Map<String, Object> _rowDeltaStates = new HashMap<>();
protected Map<String, Object> _rowTransientStates = new HashMap<>();

protected Object _initialDescendantFullComponentState = null;

// -------------------------------------------------------------- Properties
Expand Down Expand Up @@ -388,6 +387,7 @@ public String getVar() {

}


/**
* <p>Set the request-scope attribute under which the data object for the
* current row wil be exposed when iterating.</p>
Expand All @@ -399,7 +399,7 @@ public void setVar(String var) {
getStateHelper().put(PropertyKeys.var, var);

}

// ----------------------------------------------------- UIComponent Methods

/**
Expand Down Expand Up @@ -509,7 +509,7 @@ public void queueEvent(FacesEvent event) {
*
* @param event The {@link FacesEvent} to be broadcast
*
* @throws AbortProcessingException Signal the Jakarta Server Faces
* @throws AbortProcessingException Signal the JavaServer Faces
* implementation that no further
* processing on the current event should
* be performed
Expand All @@ -529,17 +529,11 @@ public void broadcast(FacesEvent event)
FacesContext context = event.getFacesContext();
// Set up the correct context and fire our wrapped event
WrapperEvent revent = (WrapperEvent) event;
if (isNestedWithinIterator(context)) {
if (isNestedWithinIterator()) {
setDataModel(null);
}
int currentRowIndex = getRowIndex();
int broadcastedRowIndex = revent.getRowIndex();
boolean needsToSetIndex = currentRowIndex != -1 || broadcastedRowIndex != -1; // #5213

if (needsToSetIndex) {
setRowIndex(broadcastedRowIndex);
}

int oldRowIndex = getRowIndex();
setRowIndex(revent.getRowIndex());
FacesEvent rowEvent = revent.getFacesEvent();
UIComponent source = rowEvent.getComponent();
UIComponent compositeParent = null;
Expand All @@ -558,10 +552,8 @@ public void broadcast(FacesEvent event)
compositeParent.popComponentFromEL(context);
}
}
setRowIndex(oldRowIndex);

if (needsToSetIndex) {
setRowIndex(currentRowIndex);
}
}

/**
Expand Down Expand Up @@ -900,7 +892,7 @@ public boolean visitTree(VisitContext context,
}
}
finally {
// Clean up - pop Jakarta Expression Language and restore old row index
// Clean up - pop EL and restore old row index
popComponentFromEL(facesContext);
if (visitRows) {
setRowIndex(oldRowIndex);
Expand Down Expand Up @@ -1283,10 +1275,11 @@ else if (viewPoolingResetMode == ComponentUtils.ViewPoolingResetMode.HARD) {
*/
protected boolean requiresRowIteration(VisitContext ctx) {

return !ctx.getHints().contains(VisitHint.SKIP_ITERATION);
return !ctx.getHints().contains(VisitHint.SKIP_ITERATION);

}


// Perform pre-decode initialization work. Note that this
// initialization may be performed either during a normal decode
// (ie. processDecodes()) or during a tree visit (ie. visitTree()).
Expand All @@ -1304,7 +1297,7 @@ protected void preDecode(FacesContext context) {
// initialization may be performed either during a normal validation
// (ie. processValidators()) or during a tree visit (ie. visitTree()).
protected void preValidate(FacesContext context) {
if (isNestedWithinIterator(context)) {
if (isNestedWithinIterator()) {
setDataModel(null);
}
}
Expand All @@ -1313,7 +1306,7 @@ protected void preValidate(FacesContext context) {
// initialization may be performed either during normal update
// (ie. processUpdates()) or during a tree visit (ie. visitTree()).
protected void preUpdate(FacesContext context) {
if (isNestedWithinIterator(context)) {
if (isNestedWithinIterator()) {
setDataModel(null);
}
}
Expand Down Expand Up @@ -1365,7 +1358,7 @@ protected void iterate(FacesContext context, PhaseId phaseId) {
}
}
}

// collect rendered columns once
List<UIColumn> renderedColumns = new ArrayList<>(getChildCount());
if (getChildCount() > 0) {
Expand Down Expand Up @@ -1481,8 +1474,8 @@ protected boolean doVisitChildren(VisitContext context, boolean visitRows) {

// Visit each facet of this component exactly once.
protected boolean visitFacets(VisitContext context,
VisitCallback callback,
boolean visitRows) {
VisitCallback callback,
boolean visitRows) {

if (visitRows) {
setRowIndex(-1);
Expand All @@ -1499,8 +1492,8 @@ protected boolean visitFacets(VisitContext context,

// Visit each UIColumn and any facets it may have defined exactly once
protected boolean visitColumnsAndColumnFacets(VisitContext context,
VisitCallback callback,
boolean visitRows) {
VisitCallback callback,
boolean visitRows) {
if (visitRows) {
setRowIndex(-1);
}
Expand All @@ -1527,8 +1520,8 @@ protected boolean visitColumnsAndColumnFacets(VisitContext context,

// Visit each column and row
protected boolean visitRows(VisitContext context,
VisitCallback callback,
boolean visitRows) {
VisitCallback callback,
boolean visitRows) {

// Iterate over our UIColumn children, once per row
int processed = 0;
Expand Down Expand Up @@ -1598,12 +1591,12 @@ protected boolean visitRows(VisitContext context,
*/
protected boolean keepSaved(FacesContext context) {

return (contextHasErrorMessages(context) || isNestedWithinIterator(context));
return (contextHasErrorMessages(context) || isNestedWithinIterator());

}


protected abstract Boolean isNestedWithinIterator(FacesContext context);
protected abstract Boolean isNestedWithinIterator();


protected boolean contextHasErrorMessages(FacesContext context) {
Expand Down Expand Up @@ -1640,7 +1633,7 @@ protected void restoreDescendantState() {
* @param context {@link FacesContext} for the current request
*/
protected void restoreDescendantState(UIComponent component,
FacesContext context) {
FacesContext context) {

// Reset the client identifier for this component
String id = component.getId();
Expand Down Expand Up @@ -1718,7 +1711,7 @@ protected void saveDescendantState() {
* @param context {@link FacesContext} for the current request
*/
protected void saveDescendantState(UIComponent component,
FacesContext context) {
FacesContext context) {

// Save state for this component (if it is a EditableValueHolder)
Map<String, SavedState> saved = (Map<String, SavedState>)
Expand Down Expand Up @@ -1784,7 +1777,7 @@ protected void saveDescendantState(UIComponent component,

}
@SuppressWarnings({"SerializableHasSerializationMethods",
"NonSerializableFieldInSerializableClass"})
"NonSerializableFieldInSerializableClass" })
class SavedState implements Serializable {

private static final long serialVersionUID = 2920252657338389849L;
Expand Down

0 comments on commit bbaecd5

Please sign in to comment.