Skip to Content
author's profile photo Former Member
Former Member

setOnClientClick

Hello,

I have in a doProcessBeforeOutput the code:

String url = myProfile.getProperty("url").toString();

String navigationAction = "EPCM.doNavigate('" + url + "',0)";

Button myButton = (Button) getComponentByName("ButtonSearch");

<b> myButton.setOnClientClick(navigationAction);</b>

at the bolded line I get "java.lang.NullPointerException"

Thanks for any feedback

Regards,

Altafin

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 02, 2004 at 10:39 AM

    Hi Altafin,

    as I know, the getComponentByName will only be something (not null) if your current request is issued from an HTMLB iView which had a button with id 'ButtonSearch'. (Typical form handling). This way you'll get something alike the button that was created in the previous request.

    Regards,

    Armin

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hello Armin,

      I have an jsp file like

      ......

      ......

      ......

      <hbj:button

      id="ButtonSearch"

      text="Search"

      width="50px"

      tooltip="Click here to search"

      onClick="onClick"

      disabled="false"

      design="STANDARD"

      />

      </hbj:button>

      .....

      .....

      .....

      and a JSPDyn page as te following:

      .....

      .....

      public void doProcessBeforeOutput() throws PageException

      {

      setJspName("my.jsp");

      }

      ....

      ....

      public void onClick(Event event) throws PageException

      {

      ...

      ...

      ...

      String url = myProfile.getProperty("url").toString();

      String navigationAction = "EPCM.doNavigate('" + url + "',0)";

      Button button = (Button) this.getComponentByName("ButtonSearch");

      <b>button.setOnClientClick(navigationAction);</b>....

      ....

      ....

      }

      So, the bolded line is not working.

      Regards,

      Altafin

  • author's profile photo Former Member
    Former Member
    Posted on Dec 02, 2004 at 10:45 AM

    Hi Altafin,

    looks like you want to <u>create</u> a button...

    So how about:

    Button button = new Button("ButtonSearch", "ButtonSearch");

    button.setOnClientClick(navigationAction);

    getComponentByName(..) is used in doProcessAfterInput to get a component out of the pagecontext. An example is reading the value of an input field:

    InputField myInputField = (InputField) getComponentByName("USER_NAME");

    if (myInputField != null) {

    this.name = myInputField.getValueAsDataType().toString();

    }

    Regards, Karsten

    edit: damn, Armin was faster 😉

    Message was edited by: Karsten Stombrowski

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.