Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

<a:commandButton not working properly.

 
Giannis nasdades
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am currently into making a seam application with ajax,jsf etc in order to make myself familiar with those technologies.
The problem is that i am trying to create a button. When this button is clicked, a method should be execute, which in turn executes a hibernate query. The results should be rendered in an <h:dataTable . When i clicked the buttong nothing at all happens... it is like the button is not registered at all...

My web page:

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://jboss.com/products/seam/taglib"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:rich="http://richfaces.org/rich"
xmlns:a="http://richfaces.org/a4j"
template="layout/template.xhtml">

<ui:define name="body">
model: <h:inputText id="searchString" value="#{motorcyclesearchaction.model}"
style="width: 165px;">
<a:support event="onkeyup" action="#{motorcyclesearchaction.find}"
reRender="searchResults" />
</h:inputText>
<a:commandButton id="findMotorcycles" value="Find Motorcycles" action="#{motorcyclesearchaction.find}"
reRender="searchResults"/>
<h:commandButton action="#{motorcyclesearchaction.find}" value="Find Motorcyclesh" reRender="searchResults"/>

<autputPanel id="searchResults">
<div class="section">

<h:dataTable id="motorcycles" value="#{motorcycles}" var="motor"
rendered="#{motorcycles.rowCount>0}">
<h:column>
<f:facet name="make">Address</f:facet>
#{motor.make}
</h:column>

</h:dataTable>
<s:link value="More results" action="#{motorcyclesearchaction.nextPage}"
rendered="#{motorcyclesearchaction.nextPageAvailable}"/>
</div>
</autputPanel>


</ui:define>

</ui:composition>




Below is my action class:




Any help is appreciated.

Thanks in advance,
giannis
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. I don't see an <h:form> tag. JSF builds on HTML, and HTML won't submit without a form. Thus, neither will JSF.

2. The signature for a JSF Action processor MUST be:

public String xxxxxx() {
....
return "zzzzz";
}

Where "zzzz" can be whatever you want the JSF navigator to key on. It's common to return "success" for successful actions and "failure" for failed ones, but all that really matters is that you return a string.

If your signature doesn't match, the action won't fire.
 
Giannis nasdades
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:1. I don't see an <h:form> tag. JSF builds on HTML, and HTML won't submit without a form. Thus, neither will JSF.

2. The signature for a JSF Action processor MUST be:

public String xxxxxx() {
....
return "zzzzz";
}

Where "zzzz" can be whatever you want the JSF navigator to key on. It's common to return "success" for successful actions and "failure" for failed ones, but all that really matters is that you return a string.

If your signature doesn't match, the action won't fire.



ok great i got it.. very stupid mistake....

thanks a lot for your help,
giannis
 
Manasa Gowda
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi.. i need help with using of <facet> tag in faces-config.xml.
how were you able to map <f:facet name="dir">
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic