nofear
unread,May 21, 2012, 7:43:49 AM5/21/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Google Web Toolkit
Hello guys,
I have a weird problem in my project , basicly speaking , I created a
widget called readingQuestionsWidget , it has UI to show the reading
questions for my exam project , in its controller class i fetch
reading questions from my database ( a question has a reading text and
4 different options below the text, so i prepared 4 radio buttons for
the options.) , for all different reading questions i put a READING
WIDGET which i created, for example , if there are 2 reading questions
i put 2 different READING WIDGETs(which they have 2 different text
boxes for the reading texts and 8 different radio buttons ( each 4
belongs to a reading text) ) on my page.
While i want to control the answers (which i check a radio button) ,
for example , the radio button for the option "A)" of two different
questions behave like connected to each other. I mean , when i check
the A) option for the 2 different questions , the first one that i
checked behave like NOT CHECKED.
here are my classes;
OgrenciReadingWidget.java
---------------------------------------
package tr.edu.gsu.yds.client.view.widget;
import com.google.gwt.i18n.client.HasDirection.Direction;
public class OgrenciReadingWidget extends Composite
{
private Label soruMetniLabel = new Label( "Reading Sorusu
Metni" );
private FormWidget formWidget = new FormWidget();
private RichTextArea readingTextBox = new RichTextArea();
private HorizontalPanel horizontalPanel1 = new HorizontalPanel();
private HorizontalPanel horizontalPanel2 = new HorizontalPanel();
private HorizontalPanel horizontalPanel3 = new HorizontalPanel();
private HorizontalPanel horizontalPanel4 = new HorizontalPanel();
private VerticalPanel verticalPanel1 = new VerticalPanel();
private RadioButton radioButtonSecenekA ;
Label lblSecenekIcerikA = new Label();
private RadioButton radioButtonSecenekB ;
Label lblSecenekIcerikB = new Label();
private RadioButton radioButtonSecenekC ;
Label lblSecenekIcerikC = new Label();
private RadioButton radioButtonSecenekD ;
Label lblSecenekIcerikD = new Label();
private Button clearButton = new Button( "Temizle" );
private Button okayButton = new Button( "Tamam" );
public OgrenciReadingWidget()
{
radioButtonSecenekA = new RadioButton( "A)" );
radioButtonSecenekB = new RadioButton( "B)" );
radioButtonSecenekC = new RadioButton( "C)" );
radioButtonSecenekD = new RadioButton( "D)" );
formWidget.getFormWidgetContainer().setWidget( 0, 0,
soruMetniLabel );
readingTextBox.setPixelSize( 450, 200 );
formWidget.getFormWidgetContainer().setWidget( 1, 0,
readingTextBox );
horizontalPanel1.setSpacing(1);
horizontalPanel1.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
verticalPanel1.add( horizontalPanel1 );
horizontalPanel1.setSize("470px", "30px");
horizontalPanel2.setSpacing(1);
horizontalPanel2.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
verticalPanel1.add( horizontalPanel2 );
horizontalPanel2.setSize("470px", "30px");
horizontalPanel3.setSpacing(1);
horizontalPanel3.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
verticalPanel1.add( horizontalPanel3 );
horizontalPanel3.setSize("470px", "30px");
horizontalPanel4.setSpacing(1);
horizontalPanel4.setVerticalAlignment( HasVerticalAlignment.ALIGN_MIDDLE );
verticalPanel1.add( horizontalPanel4 );
horizontalPanel4.setSize("470px", "30px");
horizontalPanel1.add( radioButtonSecenekA );
horizontalPanel2.add( radioButtonSecenekB );
horizontalPanel3.add( radioButtonSecenekC );
horizontalPanel4.add( radioButtonSecenekD );
lblSecenekIcerikA.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
horizontalPanel1.add( lblSecenekIcerikA );
horizontalPanel1.setCellVerticalAlignment(lblSecenekIcerikA,
HasVerticalAlignment.ALIGN_MIDDLE);
horizontalPanel1.setCellHorizontalAlignment(lblSecenekIcerikA,
HasHorizontalAlignment.ALIGN_CENTER);
lblSecenekIcerikA.setSize("426px", "20px");
lblSecenekIcerikB.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
horizontalPanel2.add( lblSecenekIcerikB );
horizontalPanel2.setCellVerticalAlignment(lblSecenekIcerikB,
HasVerticalAlignment.ALIGN_MIDDLE);
horizontalPanel2.setCellHorizontalAlignment(lblSecenekIcerikB,
HasHorizontalAlignment.ALIGN_CENTER);
lblSecenekIcerikB.setSize("426px", "20px");
lblSecenekIcerikC.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
horizontalPanel3.add( lblSecenekIcerikC );
horizontalPanel3.setCellHorizontalAlignment(lblSecenekIcerikC,
HasHorizontalAlignment.ALIGN_CENTER);
lblSecenekIcerikC.setSize("426px", "20px");
lblSecenekIcerikD.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
horizontalPanel4.add( lblSecenekIcerikD );
horizontalPanel4.setCellHorizontalAlignment(lblSecenekIcerikD,
HasHorizontalAlignment.ALIGN_CENTER);
lblSecenekIcerikD.setSize("426px", "20px");
formWidget.getFormWidgetContainer().setWidget( 2, 0,
verticalPanel1 );
clearButton.setPixelSize( 62, 25 );
formWidget.getButtonContainer().setVisible( false );
formWidget.getButtonContainer().add( clearButton );
okayButton.setPixelSize( 80, 40 );
formWidget.getButtonContainer().add( okayButton );
initWidget( formWidget );
}
public RadioButton getRadioButtonSecenekA()
{
return radioButtonSecenekA;
}
public void setRadioButtonSecenekA( RadioButton radioButtonSecenekA )
{
this.radioButtonSecenekA = radioButtonSecenekA;
}
public RadioButton getRadioButtonSecenekB()
{
return radioButtonSecenekB;
}
public void setRadioButtonSecenekB( RadioButton radioButtonSecenekB )
{
this.radioButtonSecenekB = radioButtonSecenekB;
}
public RadioButton getRadioButtonSecenekC()
{
return radioButtonSecenekC;
}
public void setRadioButtonSecenekC( RadioButton radioButtonSecenekC )
{
this.radioButtonSecenekC = radioButtonSecenekC;
}
public RadioButton getRadioButtonSecenekD()
{
return radioButtonSecenekD;
}
public void setRadioButtonSecenekD( RadioButton radioButtonSecenekD )
{
this.radioButtonSecenekD = radioButtonSecenekD;
}
public Label getSoruMetniLabel()
{
return soruMetniLabel;
}
public void setSoruMetniLabel( Label soruMetniLabel )
{
this.soruMetniLabel = soruMetniLabel;
}
public FormWidget getFormWidget()
{
return formWidget;
}
public void setFormWidget( FormWidget formWidget )
{
this.formWidget = formWidget;
}
public RichTextArea getReadingTextBox()
{
return readingTextBox;
}
public void setReadingTextBox( RichTextArea readingTextBox )
{
this.readingTextBox = readingTextBox;
}
public Button getClearButton()
{
return clearButton;
}
public void setClearButton( Button clearButton )
{
this.clearButton = clearButton;
}
public Button getOkayButton()
{
return okayButton;
}
public void setOkayButton( Button okayButton )
{
this.okayButton = okayButton;
}
public Label getLblSecenekIcerikA()
{
return lblSecenekIcerikA;
}
public void setLblSecenekIcerikA( Label lblSecenekIcerikA )
{
this.lblSecenekIcerikA = lblSecenekIcerikA;
}
public Label getLblSecenekIcerikB()
{
return lblSecenekIcerikB;
}
public void setLblSecenekIcerikB( Label lblSecenekIcerikB )
{
this.lblSecenekIcerikB = lblSecenekIcerikB;
}
public Label getLblSecenekIcerikC()
{
return lblSecenekIcerikC;
}
public void setLblSecenekIcerikC( Label lblSecenekIcerikC )
{
this.lblSecenekIcerikC = lblSecenekIcerikC;
}
public Label getLblSecenekIcerikD()
{
return lblSecenekIcerikD;
}
public void setLblSecenekIcerikD( Label lblSecenekIcerikD )
{
this.lblSecenekIcerikD = lblSecenekIcerikD;
}
}
*****************************************************
OgrenciReadingSoruSayfasi.java (The view class)
-----------------------------------------------------------------------------
package tr.edu.gsu.yds.client.view.ogrenci.sinavislemleri;
import tr.edu.gsu.yds.client.view.widget.OgrenciReadingWidget;
public class OgrenciReadingSoruSayfasi extends Composite
{
private DecoratorPanel sinavReadingSorusuPanel = new
DecoratorPanel();
private VerticalPanel sinavReadingSorusuContainer = new
VerticalPanel();
private HTML panelHeader = new HTML( "Sinav Paneli" );
private VerticalPanel container = new VerticalPanel();
private DecoratorPanel sinavReadingWidgetContainer = new
DecoratorPanel();
// Ogretmenden cekilecek.-->database sinavın gerceklestirilecegi
sınıf
private OgrenciReadingWidget ogrenciReadingWidget = new
OgrenciReadingWidget();
private OgrenciReadingWidget ogrenciReadingWidget1 = new
OgrenciReadingWidget();
public OgrenciReadingSoruSayfasi()
{
panelHeader.setHeight( "50px" );
panelHeader.setStyleName( "panelHeader" );
panelHeader.setHorizontalAlignment( HasHorizontalAlignment.ALIGN_CENTER );
ogrenciReadingWidget.getOkayButton().setVisible(false);
ogrenciReadingWidget.getClearButton().setVisible(false);
sinavReadingWidgetContainer.add( ogrenciReadingWidget );
container.add (sinavReadingWidgetContainer);
sinavReadingSorusuContainer.add( panelHeader );
sinavReadingSorusuContainer.add( container );
sinavReadingSorusuPanel.add( sinavReadingSorusuContainer );
initWidget( sinavReadingSorusuPanel );
sinavReadingSorusuPanel.setWidth( "495px" );
}
public DecoratorPanel getSinavReadingSorusuPanel()
{
return sinavReadingSorusuPanel;
}
public void setSinavReadingSorusuPanel( DecoratorPanel
sinavReadingSorusuPanel )
{
this.sinavReadingSorusuPanel = sinavReadingSorusuPanel;
}
public VerticalPanel getSinavReadingSorusuContainer()
{
return sinavReadingSorusuContainer;
}
public void setSinavReadingSorusuContainer( VerticalPanel
sinavReadingSorusuContainer )
{
this.sinavReadingSorusuContainer = sinavReadingSorusuContainer;
}
public HTML getPanelHeader()
{
return panelHeader;
}
public void setPanelHeader( HTML panelHeader )
{
this.panelHeader = panelHeader;
}
public VerticalPanel getContainer()
{
return container;
}
public void setContainer( VerticalPanel container )
{
this.container = container;
}
public DecoratorPanel getSinavReadingWidgetContainer()
{
return sinavReadingWidgetContainer;
}
public void setSinavReadingWidgetContainer( DecoratorPanel
sinavReadingWidgetContainer )
{
this.sinavReadingWidgetContainer = sinavReadingWidgetContainer;
}
public OgrenciReadingWidget getOgrenciReadingWidget()
{
return ogrenciReadingWidget;
}
public void setOgrenciReadingWidget( OgrenciReadingWidget
ogrenciReadingWidget )
{
this.ogrenciReadingWidget = ogrenciReadingWidget;
}
}
*****************************************************
OgrenciReadingSoruSayfasiController.java (The controller class for the
view class)
-------------------------------------------------------------
package tr.edu.gsu.yds.client.controller.ogrenci;
import java.util.ArrayList;
import java.util.List;
import tr.edu.gsu.yds.client.remote.YdsRemoteService;
import tr.edu.gsu.yds.client.remote.YdsRemoteServiceAsync;
import
tr.edu.gsu.yds.client.view.ogrenci.sinavislemleri.OgrenciReadingSoruSayfasi;
import tr.edu.gsu.yds.client.view.widget.OgrenciReadingWidget;
import tr.edu.gsu.yds.shared.domain.Cevap;
import tr.edu.gsu.yds.shared.domain.Sinav;
import tr.edu.gsu.yds.shared.domain.Soru;
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.user.client.Cookies;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DecoratorPanel;
public class OgrenciReadingSoruSayfasiController
{
private YdsRemoteServiceAsync ydsRemoteServiceAsync =
GWT.create( YdsRemoteService.class );
private OgrenciReadingSoruSayfasi ogrenciReadingSoruSayfasi;
private OgrenciReadingWidget ogrenciReadingWidget = new
OgrenciReadingWidget();
private Button btnTamam= new Button("Tamam");
int readingSoruSayisi = 0;
private List<Soru> sorular = new ArrayList<Soru>();
private List<Soru> readingSorulari = new ArrayList<Soru>();
private List<DecoratorPanel> dPanelList = new
ArrayList<DecoratorPanel>();
private List<Cevap> soruSecenekList = new ArrayList<Cevap>();
private List<OgrenciReadingWidget> ogrenciReadingWidgetList = new
ArrayList<OgrenciReadingWidget>();
public OgrenciReadingSoruSayfasiController( OgrenciReadingSoruSayfasi
ogrenciReadingSoruSayfasi )
{
this.ogrenciReadingSoruSayfasi = ogrenciReadingSoruSayfasi;
}
public void send(){
ogrenciReadingSoruSayfasi.getContainer().clear();
ogrenciReadingSoruSayfasi.getSinavReadingSorusuContainer().add( btnTamam );
ydsRemoteServiceAsync.getSinavList( new AsyncCallback<List<Sinav>>()
{
@Override
public void onSuccess( List<Sinav> result )
{
for ( Sinav sinav : result )
{
if( sinav.getSinavId().toString().equals( Cookies.getCookie( "sinavIdCookie" ) ) )
{
sorular.addAll( sinav.getSorular() );
for ( Soru soru : sorular )
{
if( soru.getSoruTip().equals( "Reading" )){
readingSorulari.add( soru );
readingSoruSayisi = readingSorulari.size();
dPanelList.add( ( new DecoratorPanel() ) );
ogrenciReadingWidgetList.add( new OgrenciReadingWidget() );
}
}
}
}
Window.alert( "reading soru sayisi : " + readingSoruSayisi );
Window.alert( "reading soru sayisi : " + soruSecenekList );
int j=0;
for ( OgrenciReadingWidget ogrenciReadingWidget :
ogrenciReadingWidgetList )
{
ogrenciReadingWidget.getReadingTextBox().setHTML( readingSorulari.get( j ).getSoruMetin() );
ogrenciReadingWidget.getSoruMetniLabel().setText( j+1 + ".
Reading Sorusu Metni" );
j++;
int k=0;
int c=0;
for ( OgrenciReadingWidget ogrenciReadingWidget :
ogrenciReadingWidgetList )
{
ogrenciReadingWidget.getLblSecenekIcerikA().setText( readingSorulari.get( k ).getCevaplar().get( c ).getCevapMetin() );
c++;
ogrenciReadingWidget.getLblSecenekIcerikB().setText( readingSorulari.get( k ).getCevaplar().get( c ).getCevapMetin() );
c++;
ogrenciReadingWidget.getLblSecenekIcerikC().setText( readingSorulari.get( k ).getCevaplar().get( c ).getCevapMetin() );
c++;
ogrenciReadingWidget.getLblSecenekIcerikD().setText( readingSorulari.get( k ).getCevaplar().get( c ).getCevapMetin() );
c = 0;
k++;
}
int i = 0;
for ( DecoratorPanel decoratorPanel : dPanelList )
{
decoratorPanel.setWidget( ogrenciReadingWidgetList.get( i ) );
ogrenciReadingSoruSayfasi.getContainer().add( decoratorPanel );
i++;
}
btnTamam.addClickHandler( new ClickHandler()
{
@Override
public void onClick( ClickEvent event )
{
int cevap = 0 ;
if(Window.confirm( "Tüm cevaplarınız yollansın mı ? " ))
{ Window.alert( "widget Sayisi : " +
ogrenciReadingWidgetList.size() );
int i = 0;
for ( OgrenciReadingWidget ogrenciReadingWidget :
ogrenciReadingWidgetList )
{
Window.alert( "i : " + i );
i++;
Window.alert( "A : " +
ogrenciReadingWidget.getRadioButtonSecenekA()
.getValue() );
}
}
}
} );
}
@Override
public void onFailure( Throwable caught )
{
Window.alert("Sinav çekilemedi. (Failure Error)");
}
} );
ogrenciReadingWidgetList.clear();
}
}
Any help is so much appreciated.