I have created a search word example but it seems that is not doing the string search when the button is clicked against a constant properly.
HTML:
<h1>Java Dictionary</h1>
<hr>
<h2 data-bind="text: searchPhrase"></h2>
<button data-bind:"click: changeFP">Search</button>
<h2 data-bind="text: foundPhrase, enable:isInCatalog"></h2>
JAVA:
package dew.demo.ko4j;
import net.java.html.json.*;
@Model(className="Dictionary", properties={
@Property(name="searchPhrase", type=String.class),
@Property(name="foundPhrase", type=String.class)
})
class Demo {
@ComputedProperty static boolean isInCatalog(String searchPhrase) {
if(searchPhrase.equalsIgnoreCase("Hello World!")){
return true;
}
return false;
}
@Function static void changeFP(Dictionary model){
if( model.isIsInCatalog( ) ){
model.setFoundPhrase("found");
}
}
static {
Dictionary model=new Dictionary("Hello World!","please click to search");
model.applyBindings();
}
}
PS: Please use DEW to try the example because it's where I tested.
EDIT: Ideal Scenario
DEW should have shown you one syntax error in your HTML code by highlighting it in red color. The data-bind attribute on button is no valid html. You're using a colon ":" instead of equals "=". Therefore your action is never called.
When using NetBeans it's easier to spot, because NB also gives you the error message explaining what is wrong.
Here's the updated example.