Skip to content
This repository has been archived by the owner on Sep 5, 2023. It is now read-only.

Component / Message Association #6

Closed
glassfishrobot opened this issue Aug 19, 2004 · 26 comments
Closed

Component / Message Association #6

glassfishrobot opened this issue Aug 19, 2004 · 26 comments

Comments

@glassfishrobot
Copy link

A previous version of the RI incorporated the cryptic clientId in messages (for
example, validation messages) as an attempt to show which component the message
was associated with. We need to come up with a better way of doing this. More
information from the archives:

The proper way involves adding a new property to our components that
describes the "name"/"prompt"/"label" etc. that can be incorporated
into validation messages but can still be translated, user-readable
text. Doing so is obviously an API change, but there's no way to
add this feature correctly without extending the JSF API.

– Adam

Environment

Operating System: All
Platform: All

Affected Versions

[1.2]

@glassfishrobot
Copy link
Author

Reported by rogerk

@glassfishrobot
Copy link
Author

Was assigned to rogerk

@glassfishrobot
Copy link
Author

@edburns said:
Move to p3 feature.

@glassfishrobot
Copy link
Author

@edburns said:
Give this to Roger.

@glassfishrobot
Copy link
Author

rogerk said:
Submitted initial proposal.

@glassfishrobot
Copy link
Author

rogerk said:
This change bundle implements this issue with the following key points:

  • a "label" attribute has been added to all input components

  • the value of the "label" attribute is substituted at the start
    of the implementation's default message (defined in Messages.properties).
    For example ( {1} is the placeholder for "label" value here:
    javax.faces.converter.BigDecimalConverter.DECIMAL={1}

    ''

    {0}

    '' must be a
    signed decimal number.

  • the "label" can be a binding expression that may refer to a resource bundle
    key that is the I18n'd label. For an example of this - check out
    converter04.jsp under the RI's systest/web included in the change bundle.
    (thanks to Adam Winer for his suggestion and code sample)

SECTION: Modified Files

M jsf-api/build.xml

  • added entry to create MessageFactory.java for converters
    M jsf-api/doc/input-attrs.xml
  • generated from input-props.xml
    M jsf-api/doc/input-props.xml
  • added "label" attribute
    M jsf-api/doc/standard-html-renderkit.xml
  • generated - includes "label" attribute
    M jsf-api/src/javax/faces/convert/BigDecimalConverter.java
    M jsf-api/src/javax/faces/convert/BigIntegerConverter.java
    M jsf-api/src/javax/faces/convert/BooleanConverter.java
    M jsf-api/src/javax/faces/convert/ByteConverter.java
    M jsf-api/src/javax/faces/convert/CharacterConverter.java
    M jsf-api/src/javax/faces/convert/DateTimeConverter.java
    M jsf-api/src/javax/faces/convert/DoubleConverter.java
    M jsf-api/src/javax/faces/convert/FloatConverter.java
    M jsf-api/src/javax/faces/convert/IntegerConverter.java
    M jsf-api/src/javax/faces/convert/LongConverter.java
    M jsf-api/src/javax/faces/convert/NumberConverter.java
    M jsf-api/src/javax/faces/convert/ShortConverter.java
  • added message constants; use them in ConverterException(s)
    M jsf-api/src/javax/faces/validator/DoubleRangeValidator.java
    M jsf-api/src/javax/faces/validator/LengthValidator.java
    M jsf-api/src/javax/faces/validator/LongRangeValidator.java
    M jsf-api/src/javax/faces/validator/Validator.java
  • updated javadocs;
  • include component label in the parameter array for messages
    M jsf-ri/src/javax/faces/Messages.properties
    M jsf-ri/src/javax/faces/Messages_de.properties
    M jsf-ri/src/javax/faces/Messages_es.properties
    M jsf-ri/src/javax/faces/Messages_fr.properties
  • updated to include converter messages;
  • also included new "label" value placeholder at the beginning
    of messages.
    M jsf-ri/systest/build-tests.xml
  • included new test for converter messages
    M jsf-ri/systest/src/com/sun/faces/CustomMessages.properties
  • contains a component label to illustrate the inclusion of the label
    from a resource bundle.
    M jsf-ri/systest/src/com/sun/faces/jsptest/ConverterTestCase.java
    M jsf-ri/systest/src/com/sun/faces/jsptest/ValidatorTestCase.java
  • included tests for messages
    M jsf-ri/systest/web/converter03.jsp
    M jsf-tools/template-src/MessageFactory.java
  • include specialized FacesMessage class (inner) that performs late
  • binding evaluation for message substitution parameters.

A jsf-ri/systest/web/converter04.jsp
A jsf-ri/systest/web/validator03.jsp

  • new test pages

@glassfishrobot
Copy link
Author

rogerk said:
Created an attachment (id=11)
Change bundle and new files for issue 6.

@glassfishrobot
Copy link
Author

File: issue-6.zip.gz
Attached By: rogerk

@glassfishrobot
Copy link
Author

rogerk said:
Changes to reflect last set of requests from EG. Key points:

  • a "label" attribute has been added to all input components

  • the "label" attribute value is added to the end of the Object
    parameter array (passed as an arg to MessageFactory.getMessage)

  • if the label attribute has not been specified as a literal or
    binding expression (i.e. it is null), then the component's client id
    will be used as the default label value.

  • the value of the "label" attribute is substituted at the start
    of the implementation's default message (defined in Messages.properties).
    For example ( {1} is the placeholder for "label" value here:
    javax.faces.converter.BigDecimalConverter.DECIMAL={1}

    ''

    {0}

    '' must be a
    signed decimal number.

  • the "label" can be a binding expression that may refer to a resource bundle
    key that is the I18n'd label. For an example of this - check out
    converter04.jsp under the RI's systest/web included in the change bundle.
    (thanks to Adam Winer for his suggestion and code sample)

SECTION: Modified Files

M jsf-api/build.xml
M jsf-api/doc/input-attrs.xml
M jsf-api/doc/input-props.xml
M jsf-api/doc/standard-html-renderkit.xml
M jsf-api/src/javax/faces/convert/BigDecimalConverter.java
M jsf-api/src/javax/faces/convert/BigIntegerConverter.java
M jsf-api/src/javax/faces/convert/BooleanConverter.java
M jsf-api/src/javax/faces/convert/ByteConverter.java
M jsf-api/src/javax/faces/convert/CharacterConverter.java
M jsf-api/src/javax/faces/convert/DateTimeConverter.java
M jsf-api/src/javax/faces/convert/DoubleConverter.java
M jsf-api/src/javax/faces/convert/FloatConverter.java
M jsf-api/src/javax/faces/convert/IntegerConverter.java
M jsf-api/src/javax/faces/convert/LongConverter.java
M jsf-api/src/javax/faces/convert/NumberConverter.java
M jsf-api/src/javax/faces/convert/ShortConverter.java
M jsf-api/src/javax/faces/validator/DoubleRangeValidator.java
M jsf-api/src/javax/faces/validator/LengthValidator.java
M jsf-api/src/javax/faces/validator/LongRangeValidator.java
M jsf-api/src/javax/faces/validator/Validator.java
M jsf-ri/src/javax/faces/Messages.properties
M jsf-ri/src/javax/faces/Messages_de.properties
M jsf-ri/src/javax/faces/Messages_es.properties
M jsf-ri/src/javax/faces/Messages_fr.properties
M jsf-ri/systest/build-tests.xml
M jsf-ri/systest/src/com/sun/faces/CustomMessages.properties
M jsf-ri/systest/src/com/sun/faces/jsptest/ConverterTestCase.java
M jsf-ri/systest/src/com/sun/faces/jsptest/ValidatorTestCase.java
M jsf-ri/systest/web/converter03.jsp
M jsf-tools/template-src/MessageFactory.java

A jsf-ri/systest/web/converter04.jsp
A jsf-ri/systest/web/validator03.jsp

For final EG discussion on this issue:
http://archives.java.sun.com/cgi-bin/wa?A2=ind0502&L=jsr-252-eg&F=&S=&X=1E63493BEBE56FA37C&Y=roger.kitain@sun.com&P=3866

@glassfishrobot
Copy link
Author

rogerk said:
Created an attachment (id=12)
Change Bundle For Issue 6

@glassfishrobot
Copy link
Author

File: issue-6.zip.gz
Attached By: rogerk

@glassfishrobot
Copy link
Author

rogerk said:
Created another attachment that does not include input-attrs.xml.

@glassfishrobot
Copy link
Author

rogerk said:
Created an attachment (id=14)
Latest Change bundle For Issue 6.

@glassfishrobot
Copy link
Author

File: issue-6.zip.gz
Attached By: rogerk

@glassfishrobot
Copy link
Author

@edburns said:
RK> Changes to reflect last set of requests from EG. Key points:
RK>
RK> - a "label" attribute has been added to all input components
RK> - the "label" attribute value is added to the end of the Object
RK> parameter array (passed as an arg to MessageFactory.getMessage)
RK> - if the label attribute has not been specified as a literal or
RK> binding expression (i.e. it is null), then the component's client id
RK> will be used as the default label value.
RK> - the value of the "label" attribute is substituted at the start
RK> of the implementation's default message (defined in Messages.properties).
RK> For example (

{1} is the placeholder for "label" value here:
RK> javax.faces.converter.BigDecimalConverter.DECIMAL={1}

''

{0}

'' must be a
RK> signed decimal number.
RK> - the "label" can be a binding expression that may refer to a resource bundle
RK> key that is the I18n'd label. For an example of this - check out
RK> converter04.jsp under the RI's systest/web included in the change bundle.
RK> (thanks to Adam Winer for his suggestion and code sample)
RK>
RK> SECTION: Modified Files
RK> ----------------------------
RK> M jsf-api/build.xml

Ok.

RK> M jsf-api/doc/input-attrs.xml

Don't check this in. Jayashri has CVS removed it. *-attrs.xml files
must not be checked in. They are generated by the build process.

RK> M jsf-api/doc/input-props.xml

I don't like the description.

  • A presentable name for this component that can be used
  • in messages.

How about:

A localized user presentable name for this component that can be used in messages relating to that component.

RK> M jsf-api/doc/standard-html-renderkit.xml

Did you edit this file directly? You have to edit the shr-base.xml one,
and check in the edited and generated ones.

RK> M jsf-api/src/javax/faces/convert/BigDecimalConverter.java

The javadoc for the DECIMAL appears to have a parameter list ordering
mismatch. The label is second in the javadoc, but last in the parameter
list. Looks like the javadoc is wrong.

I know you copied and pasted the method

  • private Object getLabel(FacesContext context, UIComponent component) {

into every class because there was no better place to put it,
but...there is, IMHO. Put it as a package private static method on
MessageFactory.java. MessageFactory is necessarily in every package
that would use getLabel(). Also, as a nit, there's no need for a local
variable to store the componentLabel, you can just invoke it in the
Object [] argument list. Please remove the copied and pasted getLabel()
from all converter and validator classes and use the one on
MessageFactory instead.

RK> M jsf-api/src/javax/faces/convert/BigIntegerConverter.java

  • the same apparent ordering mismatch as in BigDecimal appears to be
    here as well.

RK> M jsf-api/src/javax/faces/convert/BooleanConverter.java

  • Same nit about the local variable for componentLabel.

RK> M jsf-api/src/javax/faces/convert/ByteConverter.java

  • javadoc for both messages has two substitution params, code has two.

RK> M jsf-api/src/javax/faces/convert/DateTimeConverter.java
RK> M jsf-api/src/javax/faces/convert/DoubleConverter.java
RK> M jsf-api/src/javax/faces/convert/FloatConverter.java
RK> M jsf-api/src/javax/faces/convert/IntegerConverter.java
RK> M jsf-api/src/javax/faces/convert/LongConverter.java
RK> M jsf-api/src/javax/faces/convert/NumberConverter.java
RK> M jsf-api/src/javax/faces/convert/ShortConverter.java

  • ordering mismatch, please check all messages in these classes for
    ordering correctness.

RK> M jsf-api/src/javax/faces/validator/DoubleRangeValidator.java

  • the NOT_IN_RANGE message doesn't mention the label. Can you also please
    check that other existing messages mention the label as appropriate?

RK> M jsf-api/src/javax/faces/validator/LengthValidator.java

  • The diff on this one suffered from the ^M problem. In your revised
    change-bundle, can you please rectify it?

RK> M jsf-api/src/javax/faces/validator/LongRangeValidator.java

Ok.

RK> M jsf-api/src/javax/faces/validator/Validator.java

Ok.

RK> M jsf-ri/src/javax/faces/Messages.properties
RK> M jsf-ri/src/javax/faces/Messages_de.properties
RK> M jsf-ri/src/javax/faces/Messages_es.properties
RK> M jsf-ri/src/javax/faces/Messages_fr.properties
RK> M jsf-tools/template-src/MessageFactory.java

  • I still don't like the idea of using "the last one" as the slot for
    the label. In fact, I dislike it so much, I want to propose an
    alternate solution. This solution doesn't require changing any of the
    converters above (other than what I've already suggested).
    java.text.MessageFormat says the number in the {n}

    can be 0 - 9.
    Rather than the "last" being special, let's just use 9. That way, we
    have several chances to add parameters without changing any code
    before we run out. To affect this proposal, modify
    MessageFactory.getFormattedString() to create a 10 element array where
    the element at index 9 is the last element from the params array, and
    the first elements of the params array are copied in order at the
    beginning of the array. Any intervening elements in the 10 element
    array are filled with the empty string. Will this work?

Please produce another change-bundle.

Thanks,

Ed

@glassfishrobot
Copy link
Author

@edburns said:
status enact

@glassfishrobot
Copy link
Author

rogerk said:
M jsf-api/build.xml

  • added entry to create MessageFactory.java for converters
    M jsf-api/doc/input-attrs.xml
  • generated from input-props.xml
    M jsf-api/doc/input-props.xml
  • added "label" attribute
    M jsf-api/doc/standard-html-renderkit.xml
  • generated - includes "label" attribute
    M jsf-api/src/javax/faces/convert/BigDecimalConverter.java
    M jsf-api/src/javax/faces/convert/BigIntegerConverter.java
    M jsf-api/src/javax/faces/convert/BooleanConverter.java
    M jsf-api/src/javax/faces/convert/ByteConverter.java
    M jsf-api/src/javax/faces/convert/CharacterConverter.java
    M jsf-api/src/javax/faces/convert/DateTimeConverter.java
    M jsf-api/src/javax/faces/convert/DoubleConverter.java
    M jsf-api/src/javax/faces/convert/FloatConverter.java
    M jsf-api/src/javax/faces/convert/IntegerConverter.java
    M jsf-api/src/javax/faces/convert/LongConverter.java
    M jsf-api/src/javax/faces/convert/NumberConverter.java
    M jsf-api/src/javax/faces/convert/ShortConverter.java
  • added message constants; use them in ConverterException(s)
    M jsf-api/src/javax/faces/validator/DoubleRangeValidator.java
    M jsf-api/src/javax/faces/validator/LengthValidator.java
    M jsf-api/src/javax/faces/validator/LongRangeValidator.java
    M jsf-api/src/javax/faces/validator/Validator.java
  • updated javadocs;
  • include component label in the parameter array for messages
    M jsf-ri/src/javax/faces/Messages.properties
    M jsf-ri/src/javax/faces/Messages_de.properties
    M jsf-ri/src/javax/faces/Messages_es.properties
    M jsf-ri/src/javax/faces/Messages_fr.properties
  • updated to include converter messages;
  • also included new "label" value placeholder at the beginning
    of messages.
    M jsf-ri/systest/build-tests.xml
  • included new test for converter messages
    M jsf-ri/systest/src/com/sun/faces/CustomMessages.properties
  • contains a component label to illustrate the inclusion of the label
    from a resource bundle.
    M jsf-ri/systest/src/com/sun/faces/jsptest/ConverterTestCase.java
    M jsf-ri/systest/src/com/sun/faces/jsptest/ValidatorTestCase.java
  • included tests for messages
    M jsf-ri/systest/web/converter03.jsp
    M jsf-tools/template-src/MessageFactory.java
  • include specialized FacesMessage class (inner) that performs late
  • binding evaluation for message substitution parameters.

A jsf-ri/systest/web/converter04.jsp
A jsf-ri/systest/web/validator03.jsp

  • new test pages

@glassfishrobot
Copy link
Author

rogerk said:
Created an attachment (id=15)
Change bundle for this issue.

@glassfishrobot
Copy link
Author

File: issue-6.zip.gz
Attached By: rogerk

@glassfishrobot
Copy link
Author

@edburns said:
Looks good, r=edburns! Close this one!

@glassfishrobot
Copy link
Author

rogerk said:
checked in.

@glassfishrobot
Copy link
Author

@edburns said:
Prepare to delete "spec" subcomponent.

@glassfishrobot
Copy link
Author

@edburns said:
Move all to 1.2

@glassfishrobot
Copy link
Author

Marked as fixed on Thursday, March 4th 2010, 6:09:25 am

@glassfishrobot
Copy link
Author

@manfredriem said:
Closing resolved issue out

@glassfishrobot
Copy link
Author

This issue was imported from java.net JIRA JAVASERVERFACES_SPEC_PUBLIC-6

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant