[jboss-user] [JBoss Seam] - Re: Please Help (multiple row operations in a data table)
ask4saif
do-not-reply at jboss.com
Wed Feb 14 01:02:38 EST 2007
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
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016209#4016209
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016209
More information about the jboss-user
mailing list