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 8071621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:44:46+00:00 2026-06-05T13:44:46+00:00

I want to perform validations for my editfields.so I am writing the validations on

  • 0

I want to perform validations for my editfields.so I am writing the validations on ButtonField.setChangeListener method. If editField is empty and when clicking on the button i have to show that the field is empty. To show the message i tried by using both status.show() and dialog.alert() methods. But both are generating a NullPointerException. What is the problem? Can anyone help to solve this problem or are there any other solutions to this problem?

I have written my code like this:

btnencrypt = new ButtonField("Encrypt");
        btnencrypt.setChangeListener(new FieldChangeListener() {

            public void fieldChanged(Field field, int context) {
                // TODO Auto-generated method stub

                //getphonenos();
                System.out.println("savedPhone no are in compose encrypt:"+savedphoneno);
                encryptClicked= true;

                if (savedphoneno.equals("")) { **Getting the exception here....**

                    Dialog.alert("Please select valid contact");     
                } else {
                    if (!(savedphoneno.equals(""))) {

                        if (edmsg.getText().toString().trim().equals("")) {
                            Dialog.alert("Please enter message");

                        }else {

                            int index = savedphoneno.indexOf(",");
                            if (index < 0) {
                                encryptBTNClicked = true;
                                try {
                                    base64msgString = encrypt(savedphoneno);
                                } catch (CryptoException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                } catch (IOException e) {
                                    // TODO Auto-generated catch block
                                    e.printStackTrace();
                                }
                                edencryptmsg.setText(base64msgString);
                            } else {
                                //encryptTV.setText("");
                                edencryptmsg
                                .setText("Sending data to multiple receipients,"
                                        + "can't show the encrypted msg,as it varies");
                                //edencryptmsg.setTextColor(Color.MAGENTA);
                            }
                            btnencrypt.setEnabled(false);
                            btnclear.setEnabled(false);
                        }

                    }

                }
            }

        });
  • 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-05T13:44:48+00:00Added an answer on June 5, 2026 at 1:44 pm

    I have a useful method that I put into my StringUtils class that checks if a string is valid.

    /**
     * Tests if a string is a non-null, non-empty string. This can be called to
     * determine if the string should be displayed, or not.
     * 
     * @param text
     *        String to test.
     * @return
     *         If <code>text</code> is <code>null</code>, returns
     *         <code>false</code>. <br>
     *         If <code>text</code> is an empty string (""), returns
     *         <code>false</code>. <br>
     *         Else returns <code>true</code>.
     */
    public static boolean isNonBlankString(String text)
    {
        // null text -> false
        if (text == null)
            return false;
    
        // empty text -> false
        if ("".equals(text))
            return false;
    
        return true;
    }
    

    This will help you with Rupak’s answer.

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

Sidebar

Related Questions

I have a controller action where I perform some validations. I want to use
i want to perform client side validations.. i want to do such that when
I want when editing a model to perform some validations so I thought that
I have some code that uses the CAtlRegExp to perform some validation. In the
I have a viewModel I want to perform some more custom validation on. I
Typically when writing a web-app we want to perform validation on both client side
I want to perform simple validation against multiple fields. Please note these fields are
I want DefaultModelBinder not to perform any validation based on DataAnnotations metadata. I'm already
I want perform a easy task in android, which when receiving a call the
I want to perform rubyf action in VIM when I press F5 if the

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.