After I enter something in the search criteria and press find. The table display the rows but then Edit command button does not seem to work.
Any of you know why? I am using JSF 2 mojarra 2.0.3 and GlassFish v3.
Thanks
I have the following ManagedBean and web page:
package example.ui.web;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
@Component("testFinderAM")
@Scope("request")
public class TestFinder {
private String searchCriteria;
public String getSearchCriteria() {
return searchCriteria;
}
public void setSearchCriteria(String searchCriteria) {
this.searchCriteria = searchCriteria;
}
public String find() {
return null;
}
public String edit() {
return null;
}
public List<SimpleAddress> getAddresses() {
List<SimpleAddress> addresses = new ArrayList<SimpleAddress>();
if (hasSearchCriteria()) {
for (int i = 1; i <= 50; i++) {
addresses.add(createAddressUsing(i));
}
}
return addresses;
}
public SimpleAddress createAddressUsing(Integer id) {
return new SimpleAddress(id, "Room " + id, id + " Simple Road", "Shanghai", "Shanghai", "China");
}
public boolean hasSearchCriteria() {
return searchCriteria != null && !searchCriteria.isEmpty();
}
}
<html xmlns="
http://www.w3.org/1999/xhtml"
xmlns:ui="
http://java.sun.com/jsf/facelets"
xmlns:h="
http://java.sun.com/jsf/html"
xmlns:f="
http://java.sun.com/jsf/core">
<h:body>
<h:form prependId="false">
<h:panelGrid columns="3">
<h:outputText value="Search Criteria:"/>
<h:inputText value="#{testFinderAM.searchCriteria}"/>
<h:commandButton value="Find" action="#{testFinderAM.find}"/>
</h:panelGrid>
<h:dataTable id="addresses" var="address" value="#{testFinderAM.addresses}" border="1">
<h:column>
<f:facet name="header">Action</f:facet>
<h:commandButton value="Edit" action="#{testFinderAM.edit}" immediate="true"/>
</h:column>
<h:column>
<f:facet name="header">Address Line 1</f:facet>
#{address.line1}
</h:column>
<h:column>
<f:facet name="header">Address Line 2</f:facet>
#{address.line2}
</h:column>
<h:column>
<f:facet name="header">City</f:facet>
#{address.city}
</h:column>
<h:column>
<f:facet name="header">State</f:facet>
#{address.state}
</h:column>
<h:column>
<f:facet name="header">Country</f:facet>
#{address.country}
</h:column>
</h:dataTable>
</h:form>
</h:body>
</html>
[Message sent by forum member 'wlmang']
http://forums.java.net/jive/thread.jspa?messageID=485572