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

Ability to associate a Formatter with a class by using the @Formatted annotated [SPR-6013] #10682

Closed
spring-projects-issues opened this issue Aug 17, 2009 · 2 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Keith Donald opened SPR-6013 and commented

As a developer, I would like to be able to conveniently associated a Formatter implementation with a particular object class by simply annotating that class.

Proposal: @Formatted

/**
 * A type that can be formatted as a String for display in a UI.
 * @author Keith Donald
 * @since 3.0
 */
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Formatted {
	
	/**
	 * The Formatter that handles the formatting.
	 */
	Class<?> value();
}
@Formatted(AddressFormatter.class)
public static class Address {
	private String street;
	private String city;
	private String state;
	private String zip;
	private String country;
}

Referenced from: commits 20f5f99, 2381452

@spring-projects-issues
Copy link
Collaborator Author

Arjen Poutsma commented

I would also allow the Formatted on fields/properties, so that I can do the following:

public class Person {

  @Formatted(HomeAddressFormatter.class)
  private Address homeAddress;

  @Formatted(WorkAddressFormatter.class)
  private Address workAddress;

}

the above example is a bit contrived, but you know what I'm aiming for.

@spring-projects-issues
Copy link
Collaborator Author

Florent Ramiere commented

The @Formatted has been removed (see https://fisheye.springsource.org/browse/spring-framework/trunk/org.springframework.context/src/main/java/org/springframework/ui/format/Formatted.java#r2233)

This annotation was not re-introduced.

Should we rely solely on the AnnotationFormatterFactory to provide this feature ourselves ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

1 participant