Hi,
I wrote a jsp page with JSF, but it works abnormally.
1. After I input name in text "search", I press the ENTER, and the response is correct.
2. But, if I press the button "find", the reponse is wrong.
After checking server side log, find value of text "search" is not passed to server side,so communityList.name is null.
I dont know what is wrong
If someone can give me some suggestion, I will feel world is so good. :)
Thanks in advance.
a. jsp page
<%@ include file="/common/taglibs.jsp"%>
<f:view>
<f:loadBundle var="text" basename="#{communityList.bundleName}" />
<head>
<title><fmt:message key="communityList.title" />
</title>
<content tag="heading">
<fmt:message key="communityList.heading" />
</content>
<meta name="menu" content="CommunityMenu" />
</head>
<h:form id="editCommunity">
<h:outputLabel styleClass="desc" for="name"
value="#{text['community.name']}" />
<h:inputText styleClass="text medium" id="search"
value="#{communityList.name}">
</h:inputText>
<t:message for="search" styleClass="fieldError" />
<h:panelGroup>
<h:commandButton value="#{text['button.find']}"
action="#{communityList.find}" id="find" styleClass="button" />
</h:panelGroup>
<c:set var="buttons">
<h:commandButton value="#{text['button.add']}" action="add" id="add"
immediate="true" styleClass="button" />
<input type="button"
onclick="location.href='<c:url value="/mainMenu.html" />'"
value="<fmt:message key="button.done"/>" />
</c:set>
<%--
<c:out value="${buttons}" escapeXml="false"/> --%>
<%-- Use a non-displayed dataTable to pull communityList into request --%>
<h:dataTable var="community" value="#{communityList.communitys}"
style="display:none" />
<display:table name="communityList.communitys" cellspacing="0"
cellpadding="0" requestURI="" id="communitys" pagesize="25"
class="table communityList" export="true">
<display:column sortable="true" titleKey="community.id" media="html">
<a
href="javascript:viewCommunity('<c:out value="${communitys.id}"/>')"><c:out
value="${communitys.id}" /> </a>
</display:column>
<display:column property="id" media="csv excel xml pdf"
titleKey="community.id" />
<display:column property="name" escapeXml="true"
titleKey="community.name" sortable="true" />
<display:column property="region.name" escapeXml="true"
titleKey="community.region.name" sortable="true" />
<display:column property="description" escapeXml="true"
titleKey="community.description" sortable="true" />
<display:setProperty name="paging.banner.item_name" value="community" />
<display:setProperty name="paging.banner.items_name"
value="communitys" />
</display:table>
<c:out value="${buttons}" escapeXml="false" />
<h:commandLink action="#{communityForm.edit}" id="editCommunityLink">
<f:param name="id" value="" />
</h:commandLink>
<script type="text/javascript">
function viewCommunity(id) {
var f = document.forms['editCommunity'];
f.elements['editCommunity:_link_hidden_'].value='editCommunity:editCommunityLink';
f.elements['id'].value=id;
f.submit();
}
highlightTableRows("communitys");
</script>
</h:form>
</f:view>
2. bean
package org.appfuse.webapp.action;
import java.io.Serializable;
import java.util.List;
import org.appfuse.webapp.action.BasePage;
import org.appfuse.model.Community;
import org.appfuse.service.CommunityManager;
public class CommunityList extends BasePage implements Serializable {
private CommunityManager communityManager;
// private String name="wwwww";
private String name;
public void setCommunityManager(CommunityManager manager) {
this.communityManager = manager;
}
public List getCommunitys() {
Community community = new Community();
// log.debug("#### getCommunitys()xxxxxxx" + this.name);
log.debug("#### getCommunitys() getName()= " + getName());
community.setName(getName());
log.debug("#### community.getName()=========== " + community.getName());
// return communityManager.getCommunitys(community);
List list = communityManager.getCommunitys(community);
log.debug(" list.size() ============ "+list.size());
return list;
// return communityManager.getCommunitys(null);
}
public String find() {
// Community community = new Community();
// community.setName(getName());
// log.debug("#### getName()=========== " + community.getName());
log.debug("#### find() getName()= " + getName());
getCommunitys();
return "find";
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
cumtyjh
2007-04-12