[forge-issues] [JBoss JIRA] (FORGE-389) Property creation needs to update toString
Richard Kennard (JIRA)
jira-events at lists.jboss.org
Wed Jan 25 06:35:48 EST 2012
[ https://issues.jboss.org/browse/FORGE-389?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12661814#comment-12661814 ]
Richard Kennard commented on FORGE-389:
---------------------------------------
Can we please improve this a litte? At the moment it outputs:
public String toString() {
return "" + firstName + ", " + lastName + ", " + city + ", " + state + ", " + zip;
}
I'm not a big fan of the commas, but worse is that it outputs them even if the value is empty. So you end up with:
"John, Smith, , , , "
We need to:
1. definitely not append a field if it is empty
2. maybe not append commas
Then we'd have:
"John Smith"
> Property creation needs to update toString
> ------------------------------------------
>
> Key: FORGE-389
> URL: https://issues.jboss.org/browse/FORGE-389
> Project: Forge
> Issue Type: Feature Request
> Reporter: Richard Kennard
> Assignee: Lincoln Baxter III
> Fix For: 1.0.0.Beta4
>
>
> There are a number of places in the UI (for example, as OPTIONS inside a SELECT box) that a textual representation of an entity's value is required. I'm open to how this should be done, but something like 'whenever a property is added to an entity, it is also added to the entity's toString() method' would suffice for my purposes.
> Bonus points for limiting it to 'only required fields' or 'only the first 5 fields' :)
> For example:
> public class Customer {
> public String getFirstname() {...}
> public void setFirstname( String firstname ) {...}
> public String getSurname() {...}
> public void setSurname( String surname ) {...}
> public String toString() {
> StringBuilder builder = new StringBuilder();
> builder.append( firstname );
> builder.append( ' ' );
> builder.append( surname );
> return builder.toString()
> }
> }
> Strictly speaking this could be managed by the JSF Converter's 'getAsString' method, but I think it would be better in the Entity class?
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.jboss.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the forge-issues
mailing list