Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8347709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:26:59+00:00 2026-06-09T07:26:59+00:00

i am using integration of jsf hibernate spring primfaces in my project. i want

  • 0

i am using integration of jsf hibernate spring primfaces in my project. i want to delete row in my primefaces data table. but i am not sure about delete method in my managed bean. when i want to delete i have following error. please help me to write correct deletePersonel method.

/personel.xhtml @95,74 actionListener="#{personelMB.deletePersonel()}": java.lang.IndexOutOfBoundsException: Index: 0, Size: 0

Personel.java

@Entity
@Table(name="TBLPERSONEL")
public class Personel {
@Id
@Column(name="PERSONEL_ID")
private int personel_id;
@Column(name="PNAME")
private String pname;
@Column(name="PFAMILY")
private String pfamily;
@Column(name="PADDRESS")
private String paddress;
@Column(name="PPHONE")
private String pphone;
@OneToOne
@PrimaryKeyJoinColumn
private Manager manager;
@OneToMany(mappedBy="personel")
private Set<Stufftransfer> stufftransfers;
public Personel(){

}
//getter and setter

PersonelDao

public class PersonelDao implements IPersonelDao {
private SessionFactory sessionFactory;



public SessionFactory getSessionFactory() {
    return sessionFactory;
}

public void setSessionFactory(SessionFactory sessionFactory) {
    this.sessionFactory = sessionFactory;
}
public void deletePersonel(Personel personel) {
    getSessionFactory().getCurrentSession().delete(personel);

}

PersonelService

@Transactional(readOnly=true)
public class PersonelService implements IPersonelService{
    IPersonelDao personeldao;

    public IPersonelDao getPersoneldao() {
        return personeldao;
    }

    public void setPersoneldao(IPersonelDao personeldao) {
        this.personeldao = personeldao;
    }
@Transactional(readOnly=false)
    @Override
    public void deletePersonel(Personel personel) {
        getPersoneldao().deletePersonel(personel);

    }

PersonelBean

@ManagedBean(name="personelMB")
@SessionScoped
public class PersonelBean implements Serializable{
    private static final long serialVersionUID = 1L;

    @ManagedProperty(value="#{PersonelService}")
    IPersonelService personelservice;
    List<Personel> personelList;

    private int personel_id;
    private String pname;
    private String pfamily;
    private String paddress;
    private String pphone;
public IPersonelService getPersonelservice() {
        return personelservice;
    }
    public void setPersonelservice(IPersonelService personelservice) {
        this.personelservice = personelservice;
    }
    public List<Personel> getPersonelList() {
        personelList=new ArrayList<Personel>();
        personelList.addAll(getPersonelservice().getPersonels());
        return personelList;
    }
    public void setPersonelList(List<Personel> personelList) {
        this.personelList = personelList;
    }
public void addPersonel(){
        Personel personel=new Personel();
        personel.setPaddress(getPaddress());
        personel.setPersonel_id(getPersonel_id());
        personel.setPfamily(getPfamily());
        personel.setPname(getPname());
        personel.setPphone(getPphone());
        getPersonelservice().addPersonel(personel);
    }
    public void deletePersonel(){
        Personel personel=(Personel)personelservice.getPersonelId(personel_id);
getPersonelservice().deletePersonel(personel);
    }
//getter and setter

personel.xhtml

<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html dir="rtl" 
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
 xmlns:f="http://java.sun.com/jsf/core"
 xmlns:fn="http://java.sun.com/jsp/jstl/functions"
>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>اطلاعات پرسنلی</title>
</h:head>
<h:body>
<h1>اضافه کردن پرسنل جدید</h1>
        <h:form>

            <h:panelGrid columns="4" >
              شماره پرسنلی : 
                <h:inputText id="id" value="#{personelMB.personel_id}" 
                    size="20" required="true"
                    label="id" >
                </h:inputText>
                <br></br>
                نام : 
                <h:inputText id="name" value="#{personelMB.pname}" 
                    size="20" required="true"
                    label="Name" >
                </h:inputText>

                 نام خانوادگی: 
                <h:inputText id="family" value="#{personelMB.pfamily}" 
                    size="20" required="true"
                    label="family" >
                </h:inputText> 

                آدرس : 
                <h:inputTextarea id="address" value="#{personelMB.paddress}" 
                    cols="30" rows="10" required="true"
                    label="Address" >
                </h:inputTextarea>


          تلفن:  
                <h:inputText id="tel" value="#{personelMB.pphone}" 
                    size="20" required="true"
                    label="tel" >
                </h:inputText> 
            </h:panelGrid>

            <h:commandButton value="درج اطلاعات" action="#{personelMB.addPersonel()}" />

        </h:form>
 <h2>مشاهده اطلاعات پرسنل</h2>  
 <h:form prependId="false">  

    <p:dataTable id="dataTable" var="personel" value="#{personelMB.personelList}" rowKey="#{personelMB.personel_id}">  

        <f:facet name="header">  
            اطلاعات پرسنل 
        </f:facet>  

        <p:column>  
            <f:facet name="header">  
               شماره پرسنلی  
            </f:facet>  

            <h:outputText value="#{personel.personel_id}" />  

            <f:facet name="footer">  
                کدملی 
            </f:facet>  
        </p:column>  

        <p:column headerText="نام">  
            <h:outputText value="#{personel.pname}" />  
        </p:column>  

        <p:column headerText="نام خانوادگی">  
            <h:outputText value="#{personel.pfamily}" />  
        </p:column>  

        <p:column headerText="آدرس">  
            <h:outputText value="#{personel.paddress}" />  
        </p:column>  
   <p:column headerText="تلفن">  
            <h:outputText value="#{personel.pphone}" />  
        </p:column>
        <p:column>
      <f:facet name="حذف">
         <h:outputText value="" />
      </f:facet>
      <p:commandButton icon="ui-icon-close" title="حذف"
                       actionListener="#{personelMB.deletePersonel()}" />
   </p:column>
        <f:facet name="footer">  
            تعداد رکورد#{fn:length(personelMB.getPersonelList())} میباشد.  
        </f:facet>  

    </p:dataTable>  

</h:form>  

</h:body>
</html>

please help me to write correct deletePersonel in my PersonelBean.java.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T07:27:01+00:00Added an answer on June 9, 2026 at 7:27 am

    Change your managed bean delete method likes this;

       public void deletePersonel(int personel_id){
           Personel personel=(Personel)personelservice.getPersonelId(personel_id);
           getPersonelservice().deletePersonel(personel);
       }
    

    and also change your xhtml likes this;

      <p:commandButton icon="ui-icon-close" title="حذف"
                       actionListener="#{personelMB.deletePersonel(personel.personel_id)}" />
    

    Add refresh method to your managed bean likes this;

     public String deleteAction(Personel personel) {
        personelList.remove(personel);
        return null;
      }
    

    and edit your p:commandButton likes this;

      <p:commandButton icon="ui-icon-close" title="حذف"
                       actionListener="#{personelMB.deletePersonel(personel.personel_id)" action="#{personelMB.delectAction(personel)}"/>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing web app using Spring Integration to route my messages, but I have
Spring Webflow: 2.3.1 Spring Data: 1.0.2 JSF: 2.1.9 Primefaces: 3.3.1 I'm trying to combine
I am using JSF-Spring integration, I am calling a Spring-managed request scoped bean method
we are using Spring Integration 2.1 for persisting messages into database sent by clients.
We are using Integration Manager to create a batch of monthly invoices. I want
I am using facebook integration in to my application. But i got stop at
I am using Spring Integration to make a POST REST WebService call My outbound
I'm using integration services (SSIS), at the moment I'm getting the data from an
I am specifically using WebSphere Integration Developer V7, but I also could be using
I am trying to post a message to my twitter account using Spring Integration

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.