Examples of NewsBean


Examples of com.lichtfragmente.beans.NewsBean

           response.sendRedirect("/lichtfragmente");
        } else {
            if (request.getParameter("news")!=null) {
                //if user wants to view a certain news article
                //(will be displayed in a modal dialog requested via AJAX)
                NewsBean result=this.getNewsById(request.getParameter("news"));
                request.setAttribute("newsitem",result);

                //dispatch news article
                RequestDispatcher dispatcher=request.getRequestDispatcher("/WEB-INF/jsp/includes/home/news.jsp");
                dispatcher.forward(request,response);
View Full Code Here

Examples of com.lichtfragmente.beans.NewsBean

     * @param id ID of news article to fetch
     * @return Information associated to ID wrapped into a bean
     **/
    private NewsBean getNewsById(String id)
    throws ServletException {
        NewsBean temp=new NewsBean();

        synchronized(this) {
            try {
                int num_id=Integer.parseInt(id);

                //select specific new article
                PreparedStatement stmt=DBInterface.doQuery("SELECT * FROM news WHERE id=?");
                stmt.setInt(1,num_id);
                ResultSet result=stmt.executeQuery();

                if (result.next()) {
                    temp.setId(result.getInt("id"));
                    temp.setAuthor(result.getInt("author"));
                    temp.setDate(result.getTimestamp("date"));
                    temp.setTitle(result.getString("title"));
                    temp.setContent(GlobalHelpers.nl2br(result.getString("content")));
                }

                result.close();
                stmt.close();
                DBInterface.close();
View Full Code Here

Examples of com.lichtfragmente.beans.NewsBean

                                                           "INNER JOIN users u ON n.author=u.id " +
                                                           "ORDER BY \"date\" DESC LIMIT 10");
                ResultSet result=stmt.executeQuery();

                while (result.next()) {
                    NewsBean temp=new NewsBean();

                    temp.setId(result.getInt(1));
                    temp.getUserBean().setName(result.getString(2));
                    temp.setTitle(result.getString(3));
                    temp.setDate(result.getTimestamp(4));

                    resultList.add(temp);
                }

                result.close();
View Full Code Here

Examples of com.lichtfragmente.beans.NewsBean

                                                           "ORDER BY \"date\" DESC");
                ResultSet result=stmt.executeQuery();

                //wrap the results into beans and add the to the list
                while (result.next()) {
                    NewsBean temp=new NewsBean();

                    temp.setId(result.getInt(1));
                    temp.getUserBean().setName(result.getString(2));
                    temp.setTitle(result.getString(3));
                    temp.setDate(result.getTimestamp(4));

                    resultList.add(temp);
                }

                result.close();
View Full Code Here

Examples of test.NewsBean

  @SuppressWarnings("unchecked")
  public static List<NewsBean> creareListaNews(){
   
    List<News> n=new ArrayList<News>();
    List<NewsBean> data=new ArrayList<NewsBean>();
    NewsBean c= new NewsBean();
    EntityManagerFactory emf = Persistence
        .createEntityManagerFactory("modul3L2");
    em = emf.createEntityManager();
     em.getTransaction().begin();
    Query query = em.createQuery("SELECT n FROM News n");
    n=query.getResultList();
    int i=0;
    for(News ind:n){
      c.setContinutNews(ind.getContinut());
      c.setContinutShortNews(ind.getContinut().substring(0, 121)+"...");
     
      data.add(c);
    }
    em.getTransaction().commit();
    return data;
View Full Code Here

Examples of test.NewsBean

  @SuppressWarnings("unchecked")
  public static List<NewsBean> creareListaNews() {

    List<News> n = new ArrayList<News>();
    List<NewsBean> data = new ArrayList<NewsBean>();
    NewsBean c = new NewsBean();
    EntityManagerFactory emf = Persistence
        .createEntityManagerFactory("modul3L2");
    em = emf.createEntityManager();
    em.getTransaction().begin();
    Query query = em.createQuery("SELECT n FROM News n");
    n = query.getResultList();
    int i = 0;
    for (News ind : n) {
      c.setContinutNews(ind.getContinut());
      c.setContinutShortNews(ind.getContinut().substring(0, 90) + "...");

      data.add(c);
    }
    em.getTransaction().commit();
    em.close();
View Full Code Here

Examples of test.NewsBean

    em = emf.createEntityManager();
    em.getTransaction().begin();
    Query query = em.createQuery("SELECT n FROM News n");
    n = query.getResultList();   
    for (News ind : n) {
      NewsBean c = new NewsBean();
      c.setSelected(false);
      c.setRemove(false);
      c.setStire(ind);     
      data.add(c);
    }
    em.getTransaction().commit();
    em.close();
    return data;
View Full Code Here

Examples of test.NewsBean

  @SuppressWarnings("unchecked")
  public static List<NewsBean> creareListaNews(){
   
    List<News> n=new ArrayList<News>();
    List<NewsBean> data=new ArrayList<NewsBean>();
    NewsBean c= new NewsBean();
    EntityManagerFactory emf = Persistence
        .createEntityManagerFactory("modul3L2");
    em = emf.createEntityManager();
     em.getTransaction().begin();
    Query query = em.createQuery("SELECT n FROM News n");
    n=query.getResultList();
    int i=0;
    for(News ind:n){
      c.setContinutNews(ind.getContinut());
      c.setContinutShortNews(ind.getContinut().substring(0, 121)+"...");
     
      data.add(c);
    }
    em.getTransaction().commit();
    em.close();
View Full Code Here

Examples of test.NewsBean

  @SuppressWarnings("unchecked")
  public static List<NewsBean> creareListaNews() {

    List<News> n = new ArrayList<News>();
    List<NewsBean> data = new ArrayList<NewsBean>();
    NewsBean c = new NewsBean();
    EntityManagerFactory emf = Persistence
        .createEntityManagerFactory("modul3L2");
    em = emf.createEntityManager();
    em.getTransaction().begin();
    Query query = em.createQuery("SELECT n FROM News n");
    n = query.getResultList();   
    for (News ind : n) {
      c.setContinutNews(ind.getContinut());
      c.setContinutShortNews(ind.getContinut().substring(0, 90) + "...");
      data.add(c);
    }
    em.getTransaction().commit();
    em.close();
    return data;
View Full Code Here

Examples of test.NewsBean

  @SuppressWarnings("unchecked")
  public static List<NewsBean> creareListaNews(){
   
    List<News> n=new ArrayList<News>();
    List<NewsBean> data=new ArrayList<NewsBean>();
    NewsBean c= new NewsBean();
    EntityManagerFactory emf = Persistence
        .createEntityManagerFactory("modul3L2");
    em = emf.createEntityManager();
     em.getTransaction().begin();
    Query query = em.createQuery("SELECT n FROM News n");
    n=query.getResultList();
    int i=0;
    for(News ind:n){
      c.setContinutNews(ind.getContinut());
      c.setContinutShortNews(ind.getContinut().substring(0, 121)+"...");
     
      data.add(c);
    }
    em.getTransaction().commit();
    return data;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.