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

Faces 4.0: add support for custom attributes in ExternalContext#addResponseCookie() #4991

Merged
merged 2 commits into from
Nov 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public class ExternalContextImpl extends ExternalContext {
private Flash flash;
private boolean distributable;

private enum ALLOWABLE_COOKIE_PROPERTIES {
private enum PREDEFINED_COOKIE_PROPERTIES {
domain, maxAge, path, secure, httpOnly
}

Expand Down Expand Up @@ -776,7 +776,7 @@ public void addResponseCookie(String name, String value, Map<String, Object> pro
if (properties != null && properties.size() != 0) {
for (Map.Entry<String, Object> entry : properties.entrySet()) {
String key = entry.getKey();
ALLOWABLE_COOKIE_PROPERTIES p = ALLOWABLE_COOKIE_PROPERTIES.valueOf(key);
PREDEFINED_COOKIE_PROPERTIES p = PREDEFINED_COOKIE_PROPERTIES.valueOf(key);
Object v = entry.getValue();
switch (p) {
case domain:
Expand All @@ -795,7 +795,8 @@ public void addResponseCookie(String name, String value, Map<String, Object> pro
cookie.setHttpOnly((Boolean) v);
break;
default:
throw new IllegalStateException(); // shouldn't happen
cookie.setAttribute(key, (String) v);
break;
}
}
}
Expand Down
15 changes: 11 additions & 4 deletions impl/src/main/java/jakarta/faces/context/ExternalContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public abstract class ExternalContext {
*
* <tr>
*
* <th>Key in "values" <code>Map</code></th>
* <th>Key in "values" <code>Map</code> <span class="changed_added_4_0">(case sensitive)</span></th>
*
* <th>Expected type of value.</th>
*
Expand Down Expand Up @@ -186,6 +186,16 @@ public abstract class ExternalContext {
*
* </tr>
*
* <tr class="changed_added_4_0">
*
* <td><i>any other attribute</i> (e.g. SameSite)</td>
*
* <td>String</td>
*
* <td>setAttribute</td>
*
* </tr>
*
* </table>
*
* <p>
Expand All @@ -202,9 +212,6 @@ public abstract class ExternalContext {
* @param properties A <code>Map</code> containg key/value pairs to be passed as arguments to the setter methods as
* described above.
*
* @throws IllegalArgumentException if the <code>properties
* Map</code> is not-<code>null</code> and not empty and contains any keys that are not one of the keys listed above.
*
* @since 2.0
*/

Expand Down