You can pass a reference to the calling class to Alert class and call a
method in the calling class.. here's an example:
public class CallingClass {
public CallingClass() {
panel.Add(new AlertClass(this));
}
public void yesButtonAction() {
// Do yes button action here
}
}
public class AlertClass {
private CallingClass callingClass;
public AlertClass(CallingClass reference) {
this.callingClass = reference;
......
Yes = new Button("Yes",new ClickListener(){
public void onClick(Widget sender) {
callingClass.yesButtonAction();
result="yes";
}
});
}
}
This might work.
On Thu, Dec 4, 2008 at 8:05 AM, jagadesh <[EMAIL PROTECTED]>wrote:
>
> Hi Guys
>
> iam developing an pageheader type of widget.the real thing i donot
> want to user Window.confirm(); to showing the user a window with yes
> and no buttons . i want my own widget to show a popuppanel with a
> horizontal panel with 2 buttons like yes and no. so when a user click
> on yes a action is performed and when on no another action is done.
> iam successfull in creating a widget called AlertBox .
> here is a sample code ..
>
> public AlertClass() {
>
> popupPanel=new PopupPanel();
> popupPanel.setTitle("Popup Panel");
>
> panel = new HorizontalPanel();
> panel.setWidth("100%");
>
> messageLabel = new HTML();
> //messageLabel.setText(message);
> messageLabel.setText("jagadesh");
> panel.add(messageLabel);
> panel.setCellVerticalAlignment(messageLabel,
> HorizontalPanel.ALIGN_MIDDLE);
>
> Yes=new Button("Yes",new ClickListener(){
> public void onClick(Widget sender) {
> result="yes";
> }
> });
> Yes.setWidth("40px");
>
> No=new Button("No",new ClickListener(){
> public void onClick(Widget sender) {
> result="no";
> }
> });
> No.setWidth("40px");
>
> panel.add(Yes);
> panel.setCellHorizontalAlignment(messageLabel,
> HorizontalPanel.ALIGN_RIGHT);
> panel.add(No);
> panel.setCellHorizontalAlignment(messageLabel,
> HorizontalPanel.ALIGN_RIGHT);
>
>
> Image closeIcon = new Image("images/cross.white.png");
> closeIcon.setStyleName("close-icon");
> panel.add(closeIcon);
> panel.setCellHorizontalAlignment(closeIcon,
> HorizontalPanel.ALIGN_RIGHT);
>
> closeIcon.addClickListener(new ClickListener() {
> public void onClick(Widget sender) {
> panel.setVisible(false);
> panel.removeStyleDependentName("Error");
> panel.removeStyleDependentName("Success");
> }
> });
>
> popupPanel.add(panel);
> popupPanel.show();
> initWidget(popupPanel);
>
> }
>
>
> now my requirement is iam creating an object of the AlertClass in
> another class and showing the pageheader. but when a user click on the
> yes button an action should be done. iam unable to catch which button
> is clicked.
> how can i catch which button is clicked now.can u tell me what is the
> use of hasWidgets interface.
>
> thank in advance for every help.
>
> thank u,.
> jagadesh
>
> >
>
--
-Pav
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---