Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Have Problem with if condition...Please Help me...

  1. #1
    Junior Member
    Join Date
    Apr 2011
    Posts
    2
    My Mood
    Cool
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile Have Problem with if condition...Please Help me...

    Hi friends,
    I m new to Java.I m working on Librarian Project, I have made data model to display data in Jtable..The situation is that I have made disposal form to store information abt those book which are disposed..Now end user have three option to dispose book say Sold, Damaged and Lost..So once the when the user try to disposal the same book which is already disposed then the form shud give error msg that the book is already sold or lost whatever...I have written the code for it..but it is showing only lost situation in every scenario... so please correct my code where i m wrong..

    private void fetchAccessionRegisterData(String accessionRegisterNumber, int row) {
     
            //AccessionRegister accessionRegister = new AccessionRegister();
            //accessionRegister.setAccessionRegisterId(UUID.randomUUID().toString());
            String hql = "from AccessionRegister ar where ar.accessionRegisterNumber='" + accessionRegisterNumber + "'";
            Query q = m_Session.createQuery(hql);
     
            List<AccessionRegister> setDetails = q.list();
            Iterator<AccessionRegister> iDetails = setDetails.iterator();
            //System.out.println("RowCount:"+m_Model.getRowCount());
            if (iDetails.hasNext()) {
                m_AccessionRegister = iDetails.next();
                System.out.println("Accession Register Number:" + m_AccessionRegister.getAccessionRegisterNumber() + ":isLost:" + m_AccessionRegister.isIsLost() + ":isSold:" + m_AccessionRegister.isIsSold());
            if (m_AccessionRegister.isIsLost()) {
                    m_FeedbackHandler.handleFeedback("This item is already marked as Lost");
                    m_Model.setValueAt(" ", row, IDX_ACCESSION_REGISTER_NUMBER);
                    return;
                } else if (m_AccessionRegister.isIsSold()) {
                    m_FeedbackHandler.handleFeedback("This item is already marked as Sold");
                    m_Model.setValueAt(" ", row, IDX_ACCESSION_REGISTER_NUMBER);
                    return;
                } else if(m_AccessionRegister.equals(m_AccessionRegister.getAccessionRegisterNumber())){
                    m_Model.setValueAt(" ", row, IDX_ACCESSION_REGISTER_NUMBER);
                    m_FeedbackHandler.handleFeedback("This is an invalid Accession Register Number");
                }
     
     
                if (m_frmDisposal.isSold()) {
                    m_AccessionRegister.setIsSold(true);
                } else if (m_frmDisposal.isLost()) {
                    m_AccessionRegister.setIsLost(true);
                }
    Last edited by helloworld922; April 25th, 2011 at 03:32 PM.


  2. #2
    Member DanBrown's Avatar
    Join Date
    Jan 2011
    Posts
    134
    My Mood
    Confused
    Thanks
    1
    Thanked 12 Times in 12 Posts

    Default Re: Have Problem with if condition...Please Help me...

    try to print isLost value of the book after disposing the book. Probably your setting it true at the time of disposal.
    Thanks and Regards
    Dan Brown

    Common Java Mistakes

Similar Threads

  1. Waiting until condition
    By aussiemcgr in forum Java Theory & Questions
    Replies: 1
    Last Post: October 22nd, 2010, 09:24 AM
  2. Unable to retriving the data using WHERE condition
    By bhaskar_reddy in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: May 14th, 2010, 02:40 AM
  3. Replies: 4
    Last Post: April 27th, 2010, 01:18 AM
  4. Problem with condition
    By shamed in forum What's Wrong With My Code?
    Replies: 7
    Last Post: December 7th, 2009, 04:51 PM