Monday, 15 June 2015

java - Thin controllers -



java - Thin controllers -

i getting feet wet javafx. doing.

fxml views di controllers weld-se managed services , models trying confine ui fxml trying maintain controllers lean

problem:

while trying code ui, static ui confined within fxml. there scenarios find self adding, removing, showing, hiding elements etc.

i find myself doing within controller fx lets me configure controller method in view phone call on particular action / event. code deals dynamic ui building / manipulating , belongs within view layer. but, ends in controller making controllers fat.

javafx provides javascript integration. 1 possible way abstract view manupulation code away. add together not perfect javascript mix.

how abstract code away in java or fxml don't break lean controller paradigm ?

edit

@assylias

agreed, have thought , way java class , fxml become reusable widget. then, how wire fxml. fxml doesn't understand controller. allow wire view class fxml using fx:controller , not name controller. have this.

this view class has nil view manipulation code. create controller class. expect somehow fill form info controller. should happen when user has submitted form. in way, need tell javafx somehow ui manipulation request / event different actual info manipulation request / event.

your thoughts, sorry if verbose. tried articulate in few words could.

i think easiest solution remember controller specified in fxml view controller. it's purpose contain code modify , update view, not contain traditional mvc controller code or business logic.

for example, in project i'm working on, i'm using javafx akka actors. application written in scala. javafx view controllers contain code necessary modify view. 1 screen contains login form. when user clicks login button, view controller creates message containing username , password, , sends message actor responsible doing business logic. if actor determines there error send message view controller, , view controller can decide sort of updates need made on screen.

i've found using akka actors javafx simplifies coding application @ to the lowest degree 2 reasons.

because using actor scheme mandates sending messages between actors, there natural boundary between presentation code , business code. messages passed , forth form natural boundary. using actors replaces complexity of working threads/tasks. eliminates need code javafx.concurrent.task's long running processes.

java javafx-2

No comments:

Post a Comment