Posted By:
Thomas_Jordan
Posted On:
Thursday, March 13, 2008 03:19 AM
hi all, i tried to develope a news site in jsf where one can edit, add and remove news items. it's already working so far except the part with the editing. When i click the commandlink for editing nothing happens. When i implement a work around to get the textarea loaded, also the update action listener doesn't get called. curiously the actionlistener methods for adding and removing work fine. I suppose it has something to do with an illegal jsf structure, but i don't know how to do better. I would appreciate if someone can help me.. here is the relevant code: faces-config.xml <?xml version='1.0' encoding='UTF-8'?> xmlns:xsi="http://www.w3.org/2001/XMLSc
More>>
hi all,
i tried to develope a news site in jsf where one can edit, add and remove news items. it's already working so far except the part with the editing.
When i click the commandlink for editing nothing happens. When i implement a work around to get the textarea loaded, also the update action listener doesn't get called. curiously the actionlistener methods for adding and removing work fine.
I suppose it has something to do with an illegal jsf structure, but i don't know how to do better.
I would appreciate if someone can help me..
here is the relevant code:
faces-config.xml
<?xml version='1.0' encoding='UTF-8'?>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2">
Control
io.sls.bean.ControlBean
session
Content
io.sls.bean.ContentBean
request
Login
io.sls.bean.LoginBean
request
News
io.sls.bean.NewsBean
request
NewsBean.java
package io.sls.bean;
import static io.sls.CommunicationPool.*;
import javax.faces.event.ActionEvent;
import java.util.List;
public class NewsBean extends Bean
{
private String title;
private String newsText;
private List newsList;
private News editNews;
public NewsBean()
{
loadNewsList();
}
public String getName()
{
return "news";
}
public String getPath()
{
return "includes/news.page";
}
private void loadNewsList()
{
System.out.println("loadNewsList..");
}
public List getNewsList()
{
return newsList;
}
public void setNewsList(List list)
{ }
public String getTitle()
{
return title;
}
public void setTitle(String title)
{
this.title = title;
}
public String getNewsText()
{
return newsText;
}
public void setNewsText(String newsText)
{
this.newsText = newsText;
}
public int getEditId()
{
String newsId;
if((newsId = getRequestParameter("editId")) != null)
return Integer.parseInt(newsId);
else
return 0;
}
public void setEditId(int id)
{ }
public void editNewsEntry(ActionEvent actionEvent)
{
System.out.println("editNewsEntry has been called...");
}
public void addNewsEntry(ActionEvent actionEvent)
{
System.out.println("addNewsEntry has been called...");
}
public void updateNewsEntry(ActionEvent actionEvent)
{
System.out.println("updateNewsEntry has been called...");
}
public void deleteNewsEntry(ActionEvent actionEvent)
{
System.out.println("deleteNewsEntry has been called...");
}
}
news.jsp (jsf)
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
Thanks in advance
Thomas