Wednesday, October 31, 2012

Re: how to pass a String[] array in the declarative UI

You are trying to add logic to your UiBinder XML file which is not what it is intended to do. View-specific logic goes in the java code.

Just do it in the constructor or if you are caching your views (which is good for performance) in a dedicated method that can be called before the view is rendered by your Activity.

For the sake of an example, lets assume your UiBinder class is called MyView.

public class MyView extends Composite {

//definition of UiBinder interface and instance

@UiField
FinishButton finish;

public MyView(){
initWidget(binder.initAndBindUi(this));
}

public MyView(Rights permissions){
this();
updateUi(permissions);
}
 
public void updateUi(Rights permissions){
if( permissions == FINISH_ORDER || permissions == CANCEL_ORDER ) 
finish.setVisible(true);
}

@UiHandler("finish")
void onClickFinish(ClickEvent e){
//handle the click
}
}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/3M-vQeFosXAJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment