Note that there are some explanatory texts on larger screens.

plurals
  1. POasynccallback failures
    primarykey
    data
    text
    <p>In my app I need to add string vallues to the file(.property file, if it is important). and user enter this values in gwt GUI. Here is it's important part:</p> <pre><code>final Button submit = new Button("Submit"); addButton(submit); submit.addSelectionListener(new SelectionListener&lt;ButtonEvent&gt;() { @Override public void componentSelected(ButtonEvent ce) { keyWord.selectAll(); regexp.selectAll(); if (keyWord.getValue() != null){ setKeyWord(customerId, keyWord.getValue()); keyWord.setValue(""); } if (regexp.getValue() != null){ setRegExp(customerId, regexp.getValue()); regexp.setValue(""); } } }); } private void setKeyWord(final String customerId, final String keyword){ final AsyncCallback&lt;String&gt; callbackItems = new AsyncCallback&lt;String&gt;() { public void onFailure(final Throwable caught) { Window.alert("unable to add " + caught.toString()); } public void onSuccess(final String x) { Window.alert(x); } }; serverManagementSvc.setKeyWords(customerId, keyword, callbackItems); } private void setRegExp(final String customerId, final String regexp){ final AsyncCallback&lt;String&gt; calbackItems = new AsyncCallback&lt;String&gt;() { @Override public void onFailure(Throwable throwable) { Window.alert("unable to add " + throwable.toString()); } @Override public void onSuccess(String s) { Window.alert(s); } }; serverManagementSvc.setRegExp(customerId, regexp, calbackItems); } </code></pre> <p>So I need to use Asunccallback to call methods which are in the "server part". here are these methods:</p> <pre><code>//adds a new keyword to customers properties public String setKeyWords(String customer, String word){ try{ PropertiesConfiguration props = new PropertiesConfiguration("/home/mikhail/bzrrep/DLP/DLPServer/src/main/resources/rules.properties"); String newKeyWord = new String(props.getString("users." + customer + ".keywords" + "," + word)); props.setProperty("users." + customer + ".keywords", newKeyWord); props.save(); }catch (ConfigurationException e){ e.printStackTrace(); } return "keyword " + word + " added"; } // adds a new regexp to customer properties public String setRegExp(String customer, String regexp){ try { PropertiesConfiguration props = new PropertiesConfiguration("/home/mikhail/bzrrep/DLP/DLPServer/src/main/resources/rules.properties"); String newRegValue = new String(props.getString("users." + customer + ".regexps" + "," + regexp)); props.setProperty("users." + customer + ".regexps", newRegValue); props.save(); } catch (ConfigurationException e){ e.printStackTrace(); } return "regexp " + regexp + " added to " + customer + "'s config"; } </code></pre> <p>all interfaces are present. when I run my code And press "submit" button in gui I see that both asynccallback failured(Window.alert, as you can see, shows "null pointer exception" despite of the fact that values which I send to methods are not null). why can it be? can you suggest me something?</p> <p><strong>UPD</strong> here is error which is shown by firebug:</p> <pre><code>uncaught exception: java.lang.ClassCastException function W8(){try{null.a()}catch(a){return a}} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload