Passing AngularJS object to JSF-call -


i'm using angularfaces , want pass angular js object jsf bean method. i'm iterating on table , want put specific buttons every iteration:

<table ng-table="tableparams">     <tr ng-repeat="user in $data">         <td data-title="'user id'">{{user.id}}</td>         <td data-title="'name'">{{user.name}}</td>         <td data-title="'hide user'">             <p:commandbutton value="hide" id="hideuser" action="#{bean.hideuser({{user.id}})}"">                 <f:param name="myid" value="{{disponent.dispnr}}" />             </p:commandbutton>         </td>     </tr> </table> 

the important line is:

<p:commandbutton value="hide" id="hideuser" action="#{bean.hideuser({{user.id}})}"> 

i tried several ways, e.g.

<p:commandbutton value="hide" id="hideuser" action="#{bean.hideuser(user.id)}"> 

but nothings works. how can achieve this?

passing angularjs object jsf caused me lot of headache, too. after while i've found solution, i'm still not happy it. hope find better solution in 1 of next versions of angularfaces.

as now, can use global function aftojson serialise angularjs object , pass jsf string:

    <button class="carfilterbutton" jsf:action="#{selectionbean.showdetails()}"               ng-click="selectionbean.carasjson=aftojson(car);">show me!</button> 

(see https://github.com/stephanrauh/angularfaces/blob/master/angularfaces_2.0/angularfaces-2.0-examples/src/main/webapp/carshop/ngtable.xhtml).

on server side, can use jsonutilites of angularfaces deserialize string regular object:

    private string carasjson;      private car car;      public string getcarasjson() {         return carasjson;     }      public void setcarasjson(string carasjson) {         this.carasjson = carasjson;         int pos = carasjson.indexof(",\"$$hashkey\"");         if (pos > 0)             carasjson = carasjson.substring(0, pos) + "}";          car car = (car)  jsonutilities.readobjectfromjsonstring(carasjson, car.class);         return getcarbean().showdetails(car);     } 

(see https://github.com/stephanrauh/angularfaces/blob/master/angularfaces_2.0/angularfaces-2.0-examples/src/main/java/de/beyondjava/jsf/sample/carshop/selectionbean.java).


Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -