This content has been marked as final.
Show 6 replies
-
1. Re: Please Help (multiple row operations in a data table)
ask4saif Feb 13, 2007 9:07 AM (in response to ask4saif)any body help!
-
2. Re: Please Help (multiple row operations in a data table)
gavin.king Feb 13, 2007 10:04 AM (in response to ask4saif)If you want help, you need to show more code than that.
(1) The rest of the page, including the h:form element
(2) The Seam component you are trying to call -
3. Re: Please Help (multiple row operations in a data table)
ask4saif Feb 14, 2007 1:02 AM (in response to ask4saif)Thanx gavin for your reply, its very nice to see you helping all the people. thank you very much.
here is the code:public class SecretQuestionsAction implements SecretQuestionsLocal{ @PersistenceContext(unitName="Database") protected EntityManager em; @In(required=false,value="SecretQuestions") @Out(required=false,value="SecretQuestions") private SecretQuestions secretQuestions; @DataModel private List <SecretQuestions> allSecretQuestionsList; @DataModelSelection(value="allSecretQuestionsList") private SecretQuestions selectedSecretQuestion; @In private Context sessionContext; @In(create=true) FacesMessages facesMessages; String acknowledge = null; @Out(scope=ScopeType.CONVERSATION,required=false) Map<SecretQuestions, Boolean> secQuestionSelections; /*--------------------------------------------------------------------*/ public String deleteSelection(){ System.out.println("In the delete selection method."); for (SecretQuestions item: allSecretQuestionsList) { Boolean selected = secQuestionSelections.get(item); if (selected!=null && selected) { secQuestionSelections.put(item, false); System.out.println(item.toString()); // delete(item); } } return null; } /*--------------------------------------------------------------------*/
This was the method i want to call from my xhtml page. And now this is the jsf code in my xhtml 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:c="http://java.sun.com/jstl/core" xmlns:t="http://myfaces.apache.org/tomahawk" > <html> <head> <title>:: Secret Questions List </title> /> </head> <body> <f:view> <ui:include src="../menus/setupmenu.xhtml"/> <f:subview id="allSecretQuestionsList" rendered="#{!empty(allSecretQuestionsList)}"> <table align="center"> <tr> <td align="center"> <f:verbatim> <p><h4>Secret Questions List</h4></p> </f:verbatim> </td> </tr> <tr> <td align="center"> <h:form> <h:dataTable id="secquestionslist" rows="5" value="#{allSecretQuestionsList}" var="SecretQuestions" > <h:column> <f:facet name="header"> <h:outputText value="Select" /> </f:facet> <h:selectBooleanCheckbox value="#{secQuestionSelections[SecretQuestions]}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Question"/> </f:facet> <h:outputText value="#{SecretQuestions.secretQuestion}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Action" /> </f:facet> <h:commandButton value="Details" action="#{SecretQuestionsAction.showSecretQuestionDetails}" <c:if test="${CustomerLoginAction.update}"> <h:commandButton value="Update" action="#{SecretQuestionsAction.loadSecretQuestion}" </c:if> </h:column> </h:dataTable> <h:commandButton action="#{SecretQuestionsAction.deleteSelection}" value="Delete Selected"/> <h:panelGrid columns="1" align="center"> <t:dataScroller id="scroll_1" for="secquestionslist" fastStep="5" pageCountVar="pageCount" pageIndexVar="pageIndex" styleClass="scroller" paginator="true" paginatorMaxPages="5" paginatorTableClass="paginator" paginatorActiveColumnStyle="font-weight:bold;" immediate="true" > <f:facet name="first" > <t:graphicImage url="../images/arrow-first.gif" border="1" /> </f:facet> <f:facet name="last"> <t:graphicImage url="../images/arrow-last.gif" border="1" /> </f:facet> <f:facet name="previous" > <t:graphicImage url="../images/arrow-previous.gif" border="1" /> </f:facet> <f:facet name="next"> <t:graphicImage url="../images/arrow-next.gif" border="1" /> </f:facet> <f:facet name="fastforward"> <t:graphicImage url="../images/arrow-ff.gif" border="1" /> </f:facet> <f:facet name="fastrewind"> <t:graphicImage url="../images/arrow-fr.gif" border="1" /> </f:facet> </t:dataScroller> </h:panelGrid> </h:form> </td> </tr> <tr> <td colspan="5" align="left"> <c:if test="${CustomerLoginAction.create}"> <h:form id="navigform"> <h:commandButton id="newsecretquestion" value="Add Secret Qustion" action="#{SecretQuestionsAction.toCreateForm}" /> </h:form> </c:if> </td> </tr> </table> </f:subview> </f:view> </body> </html> </ui:composition>
Now the problem is whenever i press some command button, it performs no action. And if i remove this part "[SecretQuestions]" from the value attribute of checkbox, the buttons start working. But I can not do multiple deletion. I am really stuck here.
thanx in advance -
4. Re: Please Help (multiple row operations in a data table)
gavin.king Feb 14, 2007 2:09 AM (in response to ask4saif)SecretQuestionsAction should have an @Name annotation.
-
5. Re: Please Help (multiple row operations in a data table)
ask4saif Feb 15, 2007 1:32 AM (in response to ask4saif)thanx gavin for your reply,
I am really sorry to write to you so late.
you wrote:
SecretQuestionsAction should have an @Name annotation.
It was my mistake, i forgot to paste the @Name annotation in my post, but it is present in my code. Here it is now,@Stateless @Scope(EVENT) @Name("SecretQuestionsAction")
can you help me now, thanx alot. -
6. Re: Please Help (multiple row operations in a data table)
gavin.king Feb 15, 2007 11:05 AM (in response to ask4saif)It appears that your command button that is bound to deleteSelection is *outside* the datatable with the list of selections!
It should be in a column of the datatable if you expect to be able to use @DataModelSelection.