|
From: Sam N. <sam...@ma...> - 2004-03-08 13:41:16
|
I've been thinking about the issue of feeding back validation information to desktop applications (think: SWT or Swing) for spring-rcp. If we take Struts as an example, we need: 1. General message areas 2. Field specific feedback So, if you are filling in a form and don't fill in a required field, you really want an message to that affect next to the field. The problem is that you do not want to require that the user define each and every location for errors - it would be nice if you could just define simple JTextFields, JLabels etc. and identify them as fields. My proposed solution is to add a Factory, which is capable of taking a control (field, combobox, list etc) and a optional template, which then produces a Component which includes the field and an for feedback which will be propagated. The template will be a component which defines where the field can be and where the message will be. I suggest the following API: void addTemplate(Class componentClass, FeedbackTemplate template) void setDefaultTemplate(FeedBackTemplate template); /** * Creates a component using the control classes template or the default * template */ Component createCompoment(String fieldName, Component control) /** * Creates a component with a custom template */ Component createComponent(String fieldName, Component control, FeedbackTemplate template) I need to look over the validation stuff to work out how these FeedbackTemplates will get their text, but the interface will look something like this: FeedbackTemplate(String fieldName, Component control) Component getUI(); void showMessage(String message); getUI will be called by the factory. showMessage gets called to show the feedback. Comments? -- sam http://www.magpiebrain.com/ |