double-entry validation feature

hi!

I am work on sort of double-entry validation feature that promotes accuracy in data entry and it works like this:

After a user’s first input entry, the data is stored in temporary storage and table is cleared when a user clicks a button. And then the user must enter data for second time to match first input. If any input is not matched, it highlights unmatched input.

Now, I was doing this for client side by using javascript and it was quite ugly, so I am changing to server side. Since there are many forms like this, I am trying to create this feature that works for every pages. So, what options do I have? Is there any sort of built-in tools like this? I appreciate any comments. Btw, I am using struts.

Thanks,
dkim18Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

bloodredsunCommented:
It would require you porting your application but the only one I know where it is built in is in Struts.

Else you would need to role your own and do something like this:

if ( stringOne.equals(stringTwo) == false){ //they don't match
    RequestDispatcher rd = request.getRequestDispatcher("form.jsp?stringOne="+ stringOne );//and the rest
    rd.forward(request, response) ;
   
}

for the form input field, to re-enter the values use somehting like JSTL as they default to empty strings when the value is null

so

<input type="text" name="stringOne" value="<c:out value='${param.stringOne}'>" />
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rrzCommented:
I am not an expert, but have you considered JSF  .
> I was doing this for client side by using javascript and it was quite ugly, so I am changing to server side.    
Yes, JSF can hold client state at server and it has event listeners.  
http://java.sun.com/j2ee/1.4/docs/tutorial/doc/JSFIntro.html#wp114889
Experts please comment.           rrz
0
bloodredsunCommented:
I've never worked with JSF (it's always seemed a little immature for any big project, I'm waiting for Shale) but it does seem to do what rrz@871311 has said and he has posted a cracking link.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

rrzCommented:
>it's always seemed a little immature    
I don't think that is true today.  
Look at
http://www-106.ibm.com/developerworks/library/j-jsf1/
0
bloodredsunCommented:
Thanks rrz, that's a genuinely interesting article. It made some points about JSF that I didn't realise and frankly I'd give you points just for that link! I hadn't realised just how similar JSF was to struts in some areas, but much simpler (which is both good and bad).
0
rrzCommented:
>but much simpler (which is both good and bad).  
Please explain.
I don't use Struts.       rrz
0
bloodredsunCommented:
I like the fact that Struts has an action class as part of the controller which allows forwarding to a specific view depending on code, as well as using business delegates in the same way as JSF.
0
TimYatesCommented:
>> I don't think that is true today.  
>> Look at
>> http://www-106.ibm.com/developerworks/library/j-jsf1/

Cool, but he goes through 3 items of FUD that I hadn't considered...

1) I'm not bothered about a WYSIWYG editor (I don't use one for Struts either)
2) I know you can combine JSF and Struts if needs be, so that shouldn't be a problem
3) Heh, Struts isn't easy either ;-)  At least at the beginning, so that doesn't concern me

What does concern me, and his example compounds that fear, is that it isn't production ready yet, and that I will develop something for weeks and months, only to come up against a brick wall where JSF just doesn't go there (or doesn't work).  His example of a very simple calculator just adds to my fear that it won't handle the hundreds of thousands of items of data that my webapps have to support.  I know Struts doesn't really without a bit of kicking, but I am in the situation of "better the devil you know"

It's strange that he doesn't seem to cover that item of FUD.

I too am waiting for Shale...but Struts will do till then...

Tim
0
TimYatesCommented:
I think my fear comes from looking at loads of JSF tutorials, and the examples they give either;

a) look awful, or
b) are incredibly simple

Is there anything like Tiles for JSF?  Or do I have to use Tiles?

I love being able to make system wide design changes by editing 2 files...
0
dkim18Author Commented:
Thanks for your comments. (I read all your comments. )

I guess I need to tell more about this feature.
First, I want to make this feature to work for all pages since there are many. (so, i don't have to write for every action .)

Second, if there is any unmatched input, this feature should erase first input and a user needs to enter first and second again. Additionally, while this process, I want to make all matched input fields inactive so that a user do not change matched fields accidentally and can see those are matched fields. (I guess making fields inactive should be client side??)

Third, those matched input will be store in DB tables of course and I am thinking creating just one DAO that will handle all. (This will be a different issue, but might related to this problem.)

So, considering all those facts, what possible solution do I have?

Thanks again,
0
rrzCommented:
>what possible solution do I have?  
I don't know enough about it to know if it is good solution. I am just learning but  here is my view.  
 JSF has support for server-side validation of a single component(like a field in a form). But, you have to write custum validators to validate relationships among components.  The basic outline as I understand it is

public class BackingBean  {
         private UIInput passwordField;
         private UIInput confirmField;
...... .
    public void validateConfirmField(FacesContext context, UIComponent component,Object value){  
            if(!passwordField.getLocalValue.equals(value))// then do something
                               
   }
}
On a page,  each field can be bound to a bean property and have an attached validator.

<h:inputText    binding="#{backingBean.confirmField}"
                      validator="#{backingBean.validateConfirmField}" />  




0
bloodredsunCommented:
I'm happy with this
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JSP

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.