Skip to content

Enhancing password article. #334

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

Merged
merged 11 commits into from
Jul 16, 2025
Merged

Enhancing password article. #334

merged 11 commits into from
Jul 16, 2025

Conversation

EHandtkeBasis
Copy link
Member

MatthewHawkins
MatthewHawkins previously approved these changes May 27, 2025
@bbrennanbasis
Copy link
Member

/rebase

@github-actions github-actions bot force-pushed the password-field-enhance branch from f5d94b3 to 259f63c Compare June 17, 2025 15:43
@github-actions github-actions bot requested a review from bbrennanbasis as a code owner June 17, 2025 15:43
@hyyan
Copy link
Member

hyyan commented Jun 25, 2025

@EHandtkeBasis also add sidebar_class_name: updated-content for updated articles. That applies for other PRs too

Comment on lines 24 to 45
The `PasswordField` component stores and retrieves its value as a plain `String`, similar to a `TextField`, but with obscured visual rendering to hide the characters from view.

You can retrieve the current value using:

```java
String password = passwordField.getValue();
```

To set or reset the value programmatically:

```java
passwordField.setValue("MySecret123!");
```

If no value has been entered by the user and no default is set, the field will return an empty string (`""`).

This behavior mimics that of the native HTML `<input type="password">`, where the `.value` property holds the current input.


:::tip
Although the field visually masks the content, the returned value from `getValue()` is still stored as a plain string. Be mindful of this when handling sensitive data.
:::
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@EHandtkeBasis There's a conflict in messaging in this article. The beginning of this section starts with:

"The PasswordField component stores and retrieves its value as a plain String..."

However, one of the Best Practices points states:

"Ensure Secure Password Storage: Never store passwords in plain text...."

It's briefly mentioned in the tip, but at what point does the user have to start encrypting a password value? Is it ok to use String password = passwordField.getValue();, or should the password never be declared as a String variable?

Does the convertValue() method help resolve this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is referring to the fact that the field internally operates with plain strings, as soon as the value is retrieved it should be transformed according to the apps security standards for example with hashing. This is what the best practices refer to. Something like String password = passwordField.getValue() should be avoided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, if String password = passwordField.getValue() should be avoided, then don't include it as an example (Lines 29-31). I'd then suggest moving the tip at the bottom of this section to where that getValue() snippet used to be and state that developers should transform the value before storing it.

Copy link
Member

@bbrennanbasis bbrennanbasis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only remaining changes I'd recommend is to the getValue() section:

#334 (comment) :

Ok, if String password = passwordField.getValue() should be avoided, then don't include it as an example (Lines 29-31). I'd then suggest moving the tip at the bottom of this section to where that getValue() snippet used to be and state that developers should transform the value before storing it.

## Placeholder text
## Pattern matching

Applying a regular expression pattern to the `PasswordField` using the `setPattern()` method is strongly recommended. This allows you to enforce character rules and structural requirements, ensuring users create secure and compliant credentials. Pattern matching is especially useful when enforcing strong password rules, such as requiring a mix of uppercase and lowercase letters, numbers, and symbols.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[webforJ.BeDirect] Avoid using 'ensuring users'. Focus more on explicitly giving details about the feature.


Applying a regular expression pattern to the `PasswordField` using the `setPattern()` method is strongly recommended. This allows you to enforce character rules and structural requirements, ensuring users create secure and compliant credentials. Pattern matching is especially useful when enforcing strong password rules, such as requiring a mix of uppercase and lowercase letters, numbers, and symbols.

The pattern must follow the syntax of a [JavaScript regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions), as interpreted by the browser. The `u` (Unicode) flag is used internally to ensure accurate validation across all Unicode code points. Do **not** include forward slashes (`/`) around the pattern.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [vale] reported by reviewdog 🐶
[webforJ.BeDirect] Avoid using 'ensure accurate'. Focus more on explicitly giving details about the feature.

@bbrennanbasis bbrennanbasis requested a review from hyyan July 15, 2025 21:55
@bbrennanbasis bbrennanbasis assigned hyyan and unassigned bbrennanbasis Jul 15, 2025
@bbrennanbasis bbrennanbasis merged commit 6d5be3e into main Jul 16, 2025
2 checks passed
@bbrennanbasis bbrennanbasis deleted the password-field-enhance branch July 16, 2025 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding Field Value Details to PasswordField Documentation PasswordField: Documenting Max and Min Length Document PasswordField Pattern
4 participants