为什么我的观看次数没有加载

时间:2016-12-07 07:11:33

标签: java vaadin vaadin7

我正在制作一个学校项目,但它没有加载。 除了我在日志中打印的内容之外,还有 NO 错误日志,但我确实得到了一些关于Connector Trackers

的内容

以下是一些截图

![]
(http://pierlot.com.au:8888/repository/images/Screenshot.png)
![]
(http://pierlot.com.au:8888/repository/images/Screenshot2.png)
  

请注意顶部栏正在闪烁

这是我的代码

class information extends CustomComponent{
    /**
     * 
     */
    private static final long serialVersionUID = 1L;

    public information(String... filenames){
    VerticalLayout information = new VerticalLayout();
    Label text = new Label();
    text.setContentMode(ContentMode.HTML);
    HashMap<Integer,Integer> pageno = new HashMap<Integer,Integer>();
    pageno.put(0,0);
    Button nextb = new Button(FontAwesome.ARROW_CIRCLE_O_RIGHT);
    Button previousb = new Button(FontAwesome.ARROW_CIRCLE_O_LEFT);
    nextb.addClickListener(event -> {
    if(pageno.get(0)==filenames.length){

    }else{
        pageno.put(0,pageno.get(0)+1);
    }
    });
    previousb.addClickListener(event -> {
    // TODO Auto-generated method stub
        if(pageno.get(0)==0){

    }else{
        pageno.put(0,pageno.get(0)-1);
    }
    });
    String f = File.separator;
    String baseadress=new String("C:"+File.separator+"Users"+File.separator+"Countrywide Austral"+File.separator+"OneDrive"+File.separator+f+"ERPs"+f+"Term 4"+f);
    setCompositionRoot(information);
    information.addComponent(text);
    information.addComponent(new HorizontalLayout(nextb,previousb));
    while(true){
        try {
        TextFileProperty stri=new TextFileProperty(new File(baseadress+filenames[pageno.get(0)]+".txt"));
        text.setPropertyDataSource(stri);

        } catch (ReadOnlyException | ConversionException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
        }

    }
    }
}
public class SetiView extends CustomComponent implements View {


    private static final long serialVersionUID = 1L;
    /**
     * Submit Button
     * 
     */
    Button submit = new Button("Submit");

    @Override
    public void enter(ViewChangeEvent event) {

    getUI().getNavigator().addViewChangeListener(new ViewChangeListener() {

        /**
         * 
         */
        private static final long serialVersionUID = 120255140723534027L;

        @Override
        public boolean beforeViewChange(ViewChangeEvent event) {
        // TODO Auto-generated method stub
        return false;
        }

        @Override
        public void afterViewChange(ViewChangeEvent event) {
        // TODO Auto-generated method stub

        }
    });
    getUI().getConnectorTracker().unregisterConnector(this);
    getUI();
    UI.getCurrent().getPage();

    Label scorel = new Label();
    //submit.addClickShort
    //int score=0;
    // TODO Auto-generated method stub
    HashMap<Integer,Component> questions = new HashMap<Integer,Component>();
    HashMap<Integer,Object> interfacetransfer = new HashMap<Integer, Object>();
    interfacetransfer.put(0, 0);

    //Layouts/Tabs
    //

    /**
     *  Information Layout
     *  
     * 
     */









    /**
     *  Bibliography Layout
     *  
     * 
     */
    VerticalLayout bibliographyl= new VerticalLayout();
    FreeformQuery fq = new FreeformQuery("SELECT * FROM vwBibliographies", ((JDBCConnectionPool)getSession().getAttribute("pool")));
        Table bibliography = new Table();
        try {
        SQLContainer container = new SQLContainer(fq);
        bibliography.setContainerDataSource(container);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
        //Scanner scan= new Scanner(System.in);
        //scan.findInLine("");

       // Notification.show(new Scanner(System.in).nextLine());
        bibliographyl.addComponent(bibliography);



    /**
     *  Quiz Layout
     *  
     * 
     */
    VerticalLayout popupquiz = new VerticalLayout();
    Window quizwindows = new Window();
    quizwindows.setContent(popupquiz);
    popupquiz.addComponent(scorel);




    /**
     * Glossary Layout
     *
     * 
     */
    VerticalLayout glossary = new VerticalLayout();
    String query="Select * FROM vwGlossary";
    getSession();
    FreeformQuery glossaryquery=new FreeformQuery(query, ((JDBCConnectionPool)VaadinSession.getCurrent().getAttribute("pool")));
    Table glossarytable = new Table();
    glossarytable.setSizeFull();
    glossary.addComponent(glossarytable);
 try {
    glossarytable.setContainerDataSource(new SQLContainer(glossaryquery));
} catch (SQLException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
}





    //questions.put(1, new QuizQuestion(""))

    questions.put(0,new VerticalLayout(new Label("What state in America is SETI based in?")));

    ((AbstractComponentContainer) questions.get(0)).addComponent(new OptionGroup(""));
     ((OptionGroup)((AbstractOrderedLayout) questions.get(0)).getComponent(1)).addItems("Colorado","California","Massachusets");
    submit.addClickListener(event1 -> {
    // TODO Auto-generated method stub
    if(submit.getCaption().equals("Submit")&&popupquiz.getComponent(0).equals(questions.get(0))){
        if(((OptionGroup)((VerticalLayout)questions.get(0)).getComponent(0)).getValue().equals("California")){
        Notification.show("Correct",Type.ASSISTIVE_NOTIFICATION);
        submit.setCaption("Next");
    interfacetransfer.put(0, 1);

        }else{
        Notification.show("Incorrect",Type.ERROR_MESSAGE);
        submit.setCaption("Next");
        }}

    });
    questions.put(1,new VerticalLayout());
    ((AbstractComponentContainer) questions.get(1)).addComponent(new Label("Am I smart?"));
    ((AbstractComponentContainer) questions.get(1)).addComponent(new CheckBox());
    submit.addClickListener(event1 -> {
    // TODO Auto-generated method stub
    if(submit.getCaption().equals("Submit")&&popupquiz.getComponent(0).equals(questions.get(1))){
    if(((CheckBox)((AbstractOrderedLayout) questions.get(1)).getComponent(1)).getValue().equals(true)){
        Notification.show("Correct");
        submit.setCaption("Next");
        interfacetransfer.put(0,((Integer)interfacetransfer.get(0))+1);
    }else{
        Notification.show("Incorrect");
        submit.setCaption("Next");
    }
    }});

    for(int i=0;questions.size()-1>i;i++){
        int e=i;
        submit.addClickListener(event1 -> {
        // TODO Auto-generated method stub

        if(submit.getCaption().equals("Next")&&popupquiz.getComponent(e).equals(questions.get(e))){
            popupquiz.removeAllComponents();
            if(e!=questions.size()-1){
            popupquiz.addComponent(questions.get(e+1));
            submit.setCaption("Submit");
            popupquiz.addComponent(submit);
            scorel.setCaption(Integer.toString((int) interfacetransfer.get(0)));
            popupquiz.addComponent(scorel);
            }
        }
        });
    }

    VerticalLayout mainlayout = new VerticalLayout(MainView.nav);

TabSheet tab = new TabSheet();
mainlayout.addComponent(tab);
AbstractLayout quizl = new VerticalLayout();
tab.addTab(new information("Page 1","Page 2"),"Information");
tab.addTab(quizl,"Quiz" );
setCompositionRoot(mainlayout);

tab.addTab(bibliographyl,"Bibliography");
tab.addTab(glossary,"Glossary");

Window quiz = new Window("Quiz");
quiz.center();
tab.addSelectedTabChangeListener(event1 -> {
// TODO Auto-generated method stub
if(event1.getTabSheet().equals(tab.getTab(quizl))){
    quiz.isVisible();
}else{
    quiz.setVisible(false);
}

});
quiz.setContent(popupquiz);
popupquiz.addComponent(questions.get(0));
popupquiz.addComponent(submit);
getUI().addWindow(quiz);


getSession();
//getting current date and time using Date class
mainlayout.addComponent(new Label((String) VaadinSession.getCurrent().getAttribute("sessionupdate")));
    }

}

2 个答案:

答案 0 :(得分:1)

你的代码中有一个无限循环。确保添加break;或更新while条件,以便它不会永远循环。

while(true){
    try {
    TextFileProperty stri=new TextFileProperty(new File(baseadress+filenames[pageno.get(0)]+".txt"));
    text.setPropertyDataSource(stri);

    } catch (ReadOnlyException | ConversionException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }

}
}

答案 1 :(得分:0)

ConnectorTracker用于保持用户界面处于活动状态。可能是他需要清理他的代码(在Eclipse菜单Project-&gt; Clean上),并在编译代码不正确的情况下重建。您还可以提醒他所有类名都应该在camelcase中(例如ConnectorTracker)。