This content has been marked as final.
Show 3 replies
-
1. Re: How to delete a row in datatable using check box
exiyenaya Nov 10, 2008 4:38 PM (in response to swathis)You can use ajax support if you are using richfaces.
< h:selectManyCheckbox value="#{contentListHome.contId}" id="checkbox" required="true"> <f:selectItem itemValue="#{content.contId}" itemLabel="#{content.contId}"/> <a4j:support event="onchange" ajaxSingle="true" action="#{bean.delete}"/> </h:selectManyCheckbox>
-
2. Re: How to delete a row in datatable using check box
swathis Nov 11, 2008 5:14 AM (in response to swathis)Thank you Kaan Acar.... I have tried that also but am getting conversation error....
09:33:36,015 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=contentManagementForm:myForm:contentDetails:1:checkbox[severity=(ERROR 2), summary=(Conversion Error setting value '21250' for '#{contentListHome.contId}'. ), detail=(Conversion Error setting value '21250' for '#{contentListHome.contId}'. )] 09:33:36,515 INFO [STDOUT] *******selected category id is:2 09:33:36,531 INFO [STDOUT] *******selected category id is:2 09:33:36,765 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed. sourceId=contentManagementForm:myForm:contentDetails:1:checkbox[severity=(ERROR 2), summary=(Conversion Error setting value '21250' for '#{contentListHome.contId}'. ), detail=(Conversion Error setting value '21250' for '#{contentListHome.contId}'. )] sourceId=contentManagementForm:myForm:contentDetails:2:checkbox[severity=(ERROR 2), summary=(Conversion Error setting value '' for '#{contentListHome.contId}'. ), detail=(Conversion Error setting value '' for '#{contentListHome.contId}'. )] sourceId=contentManagementForm:myForm:contentDetails:3:checkbox[severity=(ERROR 2), summary=(Conversion Error setting value '' for '#{contentListHome.contId}'. ), detail=(Conversion Error setting value '' for '#{contentListHome.contId}'. )] sourceId=contentManagementForm:myForm:contentDetails:0:checkbox[severity=(ERROR 2), summary=(Conversion Error setting value '' for '#{contentListHome.contId}'. ), detail=(Conversion Error setting value '' for '#{contentListHome.contId}'. )]
Action class
package com.manam.mewe.agile.pms.admin; import java.io.Serializable; import java.util.ArrayList; import java.util.Calendar; import java.util.HashSet; import java.util.List; import javax.faces.context.FacesContext; import javax.faces.model.SelectItem; import javax.persistence.EntityManager; import javax.servlet.http.HttpServletRequest; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Begin; import org.jboss.seam.annotations.End; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Out; import org.jboss.seam.annotations.datamodel.DataModel; import org.jboss.seam.annotations.web.RequestParameter; import org.jboss.seam.faces.FacesMessages; import org.jboss.seam.faces.Renderer; import org.jboss.seam.framework.EntityHome; import org.jboss.seam.security.Identity; import sun.security.jca.GetInstance; import com.manam.mewe.agile.pms.admin.ContentList; import com.manam.mewe.agile.pms.audittrial.AuditTrialConstants; import com.manam.mewe.agile.pms.audittrial.AuditTrialController; import com.manam.mewe.agile.pms.entity.admin.Content; import com.manam.mewe.agile.pms.entity.audittrials.AuditTrial; @Name("contentListHome") public class ContentListHome extends EntityHome<Content> implements Serializable { @RequestParameter("contId") Long contId; // @In(scope = ScopeType.CONVERSATION, required = false) @RequestParameter("categoryId") Long categoryId; //@In(scope = ScopeType.CONVERSATION, required = false) @RequestParameter("categoryName") String catName; @In(scope=ScopeType.CONVERSATION, required=false) @Out(scope=ScopeType.CONVERSATION, required=false) Long categoryIdConversation; @In(scope=ScopeType.CONVERSATION, required=false) @Out(scope=ScopeType.CONVERSATION, required=false) String categoryNameConversation; @In Identity identity; @In(create=true) Content content; @In private FacesMessages facesMessages; @In(create = true) private Renderer renderer; @In EntityManager entityManager; ArrayList categoryList=new ArrayList(); String authorizer; String displayComponent; public SelectItem currentItem; @Override @Begin(join = true) public void create() { System.out.println("***is managed"+this.isManaged()); super.create(); } @Override @End public String persist() { Calendar cal = java.util.GregorianCalendar.getInstance() ; List result=(List) entityManager.createQuery("from Content content where value=:currentValue") .setParameter("currentValue",content.getValue()).getResultList(); if ((result == null) || (result.size() == 0)) { System.out.println("****categoryIdConversation is"+categoryIdConversation); getInstance().setContentCategoryID(getCategoryIdConversation()); getInstance().setCreatedBy(identity.getUsername()); getInstance().setCreatedOn(cal.getTime()); System.out.println("(BEFORE PERSIST)id is:"+getInstance().getContentCategoryID()); super.persist(); return "done"; } else{ facesMessages.add( "content : #{content.value} already existed"); return null; } } @Override @End public String update() { try { super.update(); } catch (Exception e) { return null; } return "done"; } @Override public Object getId() { if (id == null) { return super.getId(); } else { return id; } } @Override @End public String remove() { try { System.out.println("*********in remove*********"); getInstance().setContId(contId); System.out.println("********* Deleted *************"); super.remove(); } catch (Exception e) { return null; } return "done"; } public Long getCategoryIdConversation() { System.out .println("***categoryIdConversation(in ContentListHome.java) is:" + categoryIdConversation); return categoryIdConversation; } public void setCategoryIdConversation(Long categoryIdConversation) { this.categoryIdConversation = categoryId; } public Long getCategoryId() { return categoryId; } public void setCategoryId(Long categoryId) { this.categoryId = categoryId; } public Identity getIdentity() { return identity; } public void setIdentity(Identity identity) { this.identity = identity; } public FacesMessages getFacesMessages() { return facesMessages; } public void setFacesMessages(FacesMessages facesMessages) { this.facesMessages = facesMessages; } public Renderer getRenderer() { return renderer; } public void setRenderer(Renderer renderer) { this.renderer = renderer; } public String getCatName() { return catName; } public void setCatName(String catName) { this.catName = catName; } public String getCategoryNameConversation() { return categoryNameConversation; } public void setCategoryNameConversation(String categoryNameConversation) { this.categoryNameConversation = categoryNameConversation; } public void setId(Long id) { this.id = id; } public ArrayList getCategoryList() { return categoryList; } public void setCategoryList(ArrayList categoryList) { this.categoryList = categoryList; } public String getAuthorizer() { return authorizer; } public void setAuthorizer(String authorizer) { this.authorizer = authorizer; } public String getDisplayComponent() { return displayComponent; } public void setDisplayComponent(String displayComponent) { this.displayComponent = displayComponent; } public SelectItem getCurrentItem() { return currentItem; } public void setCurrentItem(SelectItem currentItem) { this.currentItem = currentItem; } public Long getContId() { return contId; } public void setContId(Long contId) { this.contId = contId; } public ArrayList getContentsList() { return contentsList; } public void setContentsList(ArrayList contentsList) { this.contentsList = contentsList; } public ArrayList<Content> getTempList() { return tempList; } public void setTempList(ArrayList<Content> tempList) { this.tempList = tempList; } public Content getContent() { return content; } public void setContent(Content content) { this.content = content; } }
Entitybean
package com.manam.mewe.agile.pms.entity.admin; import java.io.Serializable; import java.io.Serializable; import java.util.Date; import java.util.Set; import javax.persistence.CascadeType; import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinTable; import javax.persistence.ManyToOne; import javax.persistence.OneToOne; import javax.persistence.SequenceGenerator; import javax.persistence.Transient; import javax.persistence.UniqueConstraint; import javax.persistence.Version; import org.hibernate.validator.Length; import org.hibernate.validator.NotNull; import org.jboss.seam.annotations.Name; @Name("content") @Entity public class Content implements Serializable { private Long contId; private String value; private String createdBy; private String updatedBy; private Date createdOn; private Date updatedOn; //dummy variable private Long contentCategoryID; private ContentCategory contentcategory=null; @Id @GeneratedValue(strategy=GenerationType.SEQUENCE) public Long getContId() { return contId; } public void setContId(Long contId) { this.contId = contId; } public String getValue() { return value; } public void setValue(String value) { this.value = value; } @ManyToOne(cascade=CascadeType.PERSIST) public ContentCategory getContentcategory() { return contentcategory; } public void setContentcategory(ContentCategory ntcatcontentcategoryegory) { this.contentcategory = ntcatcontentcategoryegory; } /* * dummy variable getter&setr methods */ public Long getContentCategoryID() { return contentCategoryID; } public void setContentCategoryID(Long contentCategoryID) { this.contentCategoryID = contentCategoryID; } public String getCreatedBy() { return createdBy; } public void setCreatedBy(String createdBy) { this.createdBy = createdBy; } public String getUpdatedBy() { return updatedBy; } public void setUpdatedBy(String updatedBy) { this.updatedBy = updatedBy; } public Date getCreatedOn() { return createdOn; } public void setCreatedOn(Date createdOn) { this.createdOn = createdOn; } public Date getUpdatedOn() { return updatedOn; } public void setUpdatedOn(Date updatedOn) { this.updatedOn = updatedOn; } }
-
3. Re: How to delete a row in datatable using check box
swathis Nov 11, 2008 5:17 AM (in response to swathis)EntityQuery class
package com.manam.mewe.agile.pms.admin; import java.io.Serializable; import java.util.ArrayList; import javax.persistence.EntityManager; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.In; import org.jboss.seam.annotations.Name; import org.jboss.seam.framework.EntityController; import org.jboss.seam.framework.EntityQuery; import com.manam.mewe.agile.pms.entity.admin.Content; import com.manam.mewe.agile.pms.entity.admin.ContentCategory; @Name("contentDetails") public class ContentDetails extends EntityQuery<Content> implements Serializable { @In(scope = ScopeType.CONVERSATION, required = false) Long categoryIdConversation; @Override public String getEjbql() { System.out.println("*******selected category id is:" + categoryIdConversation); return "select co from Content co where co.contentCategoryID in (select cmg.id from contentCategory cmg where cmg.id=" + categoryIdConversation + ")"; } }