wicket-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mihir Chhaya <mihir.chh...@gmail.com>
Subject Re: how to handle null pointer exception while submit button
Date Fri, 27 Jun 2014 13:16:47 GMT
Kumar,

I ran following (copied from your code) and it is showing me the value for
memberNumber. No NPE. Since you have String as memberID, I have assigned
String type to the models and property variable.


PropertyModel<String> memberIdModel=new
PropertyModel<String>(this,"memberNumber");
        TextField<String> memberIdField = new
TextField<String>("memberId",memberIdModel);


Form<?> form = new Form<Void>("form"){
 /**
 *
 */
private static final long serialVersionUID = 1L;

/* (non-Javadoc)
 * @see org.apache.wicket.markup.html.form.Form#onSubmit()
 */
@Override
protected void onSubmit() {
 System.out.println(memberNumber.equals("5566"));
}
};
add(form);

As Sven has mentioned, stacktrace might be more helpful.




On Fri, Jun 27, 2014 at 6:16 AM, kumar ramanathan <kumarramanatha@gmail.com>
wrote:

>
>         PropertyModel memberIdModel=new PropertyModel(this,"memberNumber");
>         PropertyModel lossIdModel=new PropertyModel(this,"lossNumber");
>         TextField memberIdField = new TextField("memberId",memberIdModel);
>         TextField lossIdField = new TextField("lossId",lossIdModel);
>
> Form form=new Form("form1"){
>             public void onSubmit(){
>
>
>                 flag=0;
>                 assignments.clear();
>                 estimates.clear();
>                 assignments.add(new
> AssignmentDB("MemberId","LossId","AssignemntId","DOL"));
>                 assignments.add(new
> AssignmentDB("1234","001","1357","10/12/1067"));
>                 assignments.add(new
> AssignmentDB("1234","001","1358","10/12/1067"));
>                 assignments.add(new
> AssignmentDB("1234","003","1357","10/12/1067"));
>
>                 for(int i=1;i<assignments.size();){
>
> if(memberNumber.equals(assignments.get(i).getMemberId())){
>                         System.out.println("inside2");
>
> if(lossNumber.equals(assignments.get(i).getLossId())){
>                             System.out.println("inside3");
>                             i=i+1;
>                         }
>                         else{
>                             assignments.remove(i);
>                             i=1;
>                         }
>
>                     }
>                     else{
>                         assignments.remove(i);
>                         i=1;
>                     }
>
>                 }
>                 if(assignments.size()<=1){
>
>                     setAsssignmentLabel("Assignments Output");
>                     assignments.clear();
>                     setAsssignmentResult("No Assignments for the given
> member number and loss number");
>                     setEstimateResult("");
>                     setEstimateLabel("");
>                 }
>                 else{
>                     setAsssignmentLabel("Assignments Ouput");
>
>                     setAsssignmentResult("");
>                     setEstimateResult("");
>                 }
>               }//form submit
>
>
>              };//form
>
>         form.add(memberIdField);
>         form.add(lossIdField);
>         add(form);
>
>
> This is my code snippet . Kindly help me.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/how-to-handle-null-pointer-exception-while-submit-button-tp4666392p4666396.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message