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

  • SEARCH
  • Home
  • 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 8839719
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:18:08+00:00 2026-06-14T10:18:08+00:00

I have a Javabean with a date_observed field. Now I am trying to create

  • 0

I have a Javabean with a date_observed field. Now I am trying to create a form where a user can search for entries between a start and end date.

Should I create another Javabean that extends this bean to have a start and end date field so that I can populate these field from request parameter?

I’d like to cleanly pass a bean to my Dao for SQL string generation and also have a way to do form validation if they enter incorrect date format.

Typically I would do

public void processDate_observed(HttpServletRequest request, Comment comment) {
    String _date = FormUtil.getFieldValue(request, FIELD_DATE_OBSERVED);
    if (!"".equals(_date) && _date != null) {
        try {
            Date date = DateUtil.parse(_date);
            com.setDate_observed(date);
        } catch (ParseException e) {
            setError(FIELD_DATE_OBSERVED, e.getMessage());
        }
    }
}

But my Comment Javabean does not have fields for start_date and end_date

And for dao.search(comment)

    public List<Evaluatee> search(Comment comment) {
   SQL = ".... where date_observed > ? AND date_observed <= ?
         ps.setDate(1, comment.EXTENDED FIELD???)
         ps.setDate(2, comment.EXTENDED FIELD???)
   ...
    }

What is the best practice here? Creat a whole new Javabean, extend my original bean or pass along the two date fields to Dao? But then how do you pass form validation back to form if I don’t have the dates in a bean?

  • 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-14T10:18:09+00:00Added an answer on June 14, 2026 at 10:18 am

    Is a good practice that in your DAO class you have a serch method with a start and end date as parameters.

    public List<Evaluatee> search(String startDate, String endDate) {
    ///CODE GOES HERE
    }
    

    It’s not necessary that the DAOs needs to have a Comment object as an argument, the rule is that for each table of the data base need to be a class with the same fields as in the table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed an own javaBean for Swing. Now I'm trying to catch two
Have seen some similar questions: What is the difference between a JavaBean and a
Here's my issue: I have a html form that after a user fills in
I have a JavaBean that reads and processes an XML file. The XML file
Have a painfully simple blog Post creator, and I'm trying to check if the
I have written my jsp using <display:table> to display search results. The <display:table> requires
I have implemented a few Java applications now, only desktop applications so far. I
I have application that look like below without spring (prior) UI-> service --> javabean
Have anyone tried to import user defined classes in jasper report (.jrxml file)? I
I thought this should be obvious but I can't find it. Now that fields

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.