Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

We have a complex web form (we use GWT/GXT stack) with lots of input elements of different types (text fields, selects, checkboxes, buttons), and behavior of these elements depends on each other.

Now it means, to set form element state correctly, it's necessary to know what happened to it (user input occurred or an event came from server) and state of other elements of that form.

So, the question is what best practices to maintain code for such a complex web form in clean and comprehensible state? Now it seems that ideal solution would employ some form of declarative DSL to describe said behavior.

Initial brain storming produced following kind of Java DSL (this is just to give an idea what I mean, no any real DSL exists right now):

private Event whenStopOrderChanged;
private Predicate parentPriceValid;
private Command calculateStopPrice;

public void initRules() {
    whenStopOrderChanged.and(parentPriceValid).then(calculateStopPrice);
}

So, could you please share your ideas/experience solving such kind of task?

Thank you!

share|improve this question
    
When you say "behavior of these elements depends on each other" it makes me want to enable/disable input controls based on user action. E.g. don't even let the user do whatever it is that causes StopOrderChanged until there is a valid parentPrice. I.e. OnParentPriceChanged { if parentPriceValid { StopOrder.enabled = True (I hope that that makes some sort of sense –  Mawg Jan 27 at 14:48

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.