have you run this in hosted mode? (or "development mode")

I don't see a
public RadioButton arbys[] = new RadioButton[#];
anywhere so I would think you would be getting a NullPointerException
when you try and do access the 0th element.

On Oct 25, 12:35 am, Jon <[email protected]> wrote:
> The code: works fine when commented-out rb10 is active; when
> implemented as shown with array element, displays nothing:
>
> package com.wordsbythebay.client;
>
> import com.google.gwt.core.client.EntryPoint;
> import com.google.gwt.core.client.GWT;
> import com.google.gwt.event.dom.client.ClickEvent;
> import com.google.gwt.event.dom.client.ClickHandler;
> import com.google.gwt.event.dom.client.KeyCodes;
> import com.google.gwt.event.dom.client.KeyUpEvent;
> import com.google.gwt.event.dom.client.KeyUpHandler;
> import com.google.gwt.user.client.rpc.AsyncCallback;
> import com.google.gwt.user.client.ui.Button;
> import com.google.gwt.user.client.ui.DialogBox;
> import com.google.gwt.user.client.ui.HTML;
> import com.google.gwt.user.client.ui.Label;
> import com.google.gwt.user.client.ui.RootPanel;
> import com.google.gwt.user.client.ui.FlowPanel;
> import com.google.gwt.user.client.ui.TextBox;
> import com.google.gwt.user.client.ui.VerticalPanel;
> import com.google.gwt.user.client.ui.ScrollPanel;
> import com.google.gwt.user.client.ui.RadioButton;
>
> /**
>  * Entry point classes define <code>onModuleLoad()</code>.
>  */
> public class GrammarFun implements EntryPoint {
>
>         /**
>          * Create a remote service proxy to talk to the server-side Question
> service.
>          */
>         private final QuestionServiceAsync questionService = GWT.create
> (QuestionService.class);
>
>         public RadioButton rb11 = null;
>                 //      public RadioButton rb10 = null;
>         public RadioButton arbys[] = null;
>
>         /**
>          * This is the entry point method.
>          */
>         public void onModuleLoad() {
>                 final RadioButton rb4 = new RadioButton("myGradioGroup2", 
> "goes");
>
>                 String[] myStringArray = {"eat", "eats"};
>                 final Question myQuestion = new Question("the boy", 
> myStringArray,
>                         "his lunch", "s-v agreement");
>
>                 // add a flow panel to the root panel
>                 final FlowPanel panel = new FlowPanel();
>                 //              final ScrollPanel panel = new ScrollPanel();
>                 RootPanel.get().add(panel);
>
>                 // Create a simple popup box for debugging
>                 final DialogBox dBox = new DialogBox();
>                 dBox.setText("would get next question from server");
>                 dBox.setAnimationEnabled(true);
>                 final Button cB = new Button("Close");
>                 cB.getElement().setId("closeButton2");
>                 VerticalPanel dVP = new VerticalPanel();
>                 dVP.addStyleName("dialogVPanel");
>                 dVP.add(new HTML("wadda wadda"));
>                 dVP.add(cB);
>                 dBox.setWidget(dVP);
>                 // Add a handler to close the DialogBox
>                 cB.addClickHandler(new ClickHandler() {
>                         public void onClick(ClickEvent event) {
>                                 dBox.hide();
>                         }
>                 });
>
>                 // Create a handler for the radio button
>                 class MyRadHandler implements ClickHandler {
>
>                         int groupCount = 0;
>
>                         /**
>                          * Fired when the user clicks on the radio Button.
>                          */
>                         public void onClick(ClickEvent event) {
>                                         checkAnswer();
>                                         // if correct . . .
>                                         //                                    
>   getNextQuestion();
>                         }
>                         /**
>                          * check the user's answer
>                          */
>                         void checkAnswer() {
>
>                                 questionService.getQuestion(new 
> AsyncCallback<Question>() {
>
>                                         public void onFailure(Throwable 
> caught) {
>                                                 // might do better to just 
> throw exception here
>                                                 dBox.setText("radio button 
> error getting question from server");
>                                                 dBox.center();
>                                                 cB.setFocus(true);
>                                         }
>                                         public void onSuccess(Question 
> result) {
>
>                                                         //                    
>                           if (rb10 != null && rb10.getValue() == true)
>                                                 if (arbys[0] != null && 
> arbys[0].getValue() == true)
>                                                         panel.add(new 
> HTML("[user clicked first button]"));
>                                                 else if (rb11 != null && 
> rb11.getValue() == true)
>                                                         panel.add(new 
> HTML("[user clicked second button]"));
>                                                 else if (arbys[0] != null && 
> rb11 != null)
>                                                         return;
>
>                                                 panel.add(new HTML("<br>"));
>
>                                                 String groupName = 
> "myGeneratedRadioGroup" + ++groupCount;
>                                                 panel.add(new 
> HTML(result.start));
>                                                 // XXX hardwires in exactly 
> two choices
>                                                 //                            
>                   rb10 = new RadioButton(groupName, result.choices[0]);
>                                                 arbys[0] = new 
> RadioButton(groupName, result.choices[0]);
>                                                 rb11 = new 
> RadioButton(groupName, result.choices[1]);
>                                                 //                            
>                   panel.add(rb10);
>                                                 panel.add(arbys[0]);
>                                                 panel.add(rb11);
>                                                 panel.add(new 
> HTML(result.end));
>                                                 panel.add(new HTML("<br>"));
>
>                                                 String wholeThing = "";
>                                                 wholeThing = result.start + " 
> ";
>                                                 for (int i = 0; i < 
> result.choices.length; i++)
>                                                         wholeThing = 
> wholeThing + result.choices[i] + " ";
>                                                 wholeThing = wholeThing + 
> result.end + " ";
>                                                 wholeThing = wholeThing + "(" 
> + result.hint+ ")";
>
>                                                 //                            
>                   panel.add(new HTML("[" + groupName + wholeThing + "]"));
>
>                                                 MyRadHandler aHandler = new 
> MyRadHandler();
>                                                 //                            
>                   rb10.addClickHandler(aHandler);
>                                                 
> arbys[0].addClickHandler(aHandler);
>                                                 
> rb11.addClickHandler(aHandler);
>
>                                         }
>                                 });
>
>                         }
>                 }
>
>                 // add a handler for the radio button
>                 MyRadHandler radHandler = new MyRadHandler();
>                 Button b = new Button("Start!", radHandler);
>                 panel.add(b);
>
>         }
>
> }
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to