JSF component created in encodeBegin not visible in decode [duplicate] - jsf-2

This question already exists:
Closed 10 years ago.
Possible Duplicate:
Primefaces commandButton in custom component action listener not called
I have created custom component which extends UIComponentBase. I am creating
some component in encodeBegin (CommandButton from Primefaces), but when
is decode triggered by user clicking button when I look for button it is not
present in UIViewRoot and not in this.getChildren().
It seems that it is a new instance of component invoked when decode is trigered and components are not present.
What is wrong?
Some code is in:
code
If you want I can send whole code.
I found that this technique is used in PrimeFaces and other software, but can you explain why values retrieved from getStateHelper().eval("someKey"); are always null in decode?
Probably problem on my site, but I can not solve it?
This is link to thread I started:
problem description in more details

It seems that it is a new instance of component invoked when decode is trigered and components are not present.
That's correct. Component instances are not stored in the view state. Instead, the component's state is stored in the view state. The component's state can be managed by the helper class StateHelper which is available by UIComponent#getStateHelper().
So, during encode do:
// ...
getStateHelper().put("someKey", someKey);
And during decode do:
SomeKey someKey = (SomeKey) getStateHelper().eval("someKey");
// ...
See also:
How to save state when extending UIComponentBase
JSF composite component - weird behavior when trying to save state
JSF 2 Custom components having Expression Language for attribute value don't trigger the attribute setter

Related

ObjectContext instance has been disposed when using BrightIdeasSoftware's ObjectListView

Trying to add a filter for the list. I have a textbox and an event that does this when the textbox text changes:
this.objectListView1.ModelFilter = TextMatchFilter.Contains(this.objectListView1, filterString.Text);
When I key in a character into the textbox I am getting the following error:
System.ObjectDisposedException: 'The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.'
I am using Entity Framework to get the data for the list view. I fill my data when the form with the listview loads using a method for that.
What is causing the error? How do I correct this?

How to fetch value of Dataslots in custom Jsp in Savvion BPM?

I am using Progress Savvion BPM Studio 8.0.
I want to use value of "Dataslot" (variable) in custom jsp page with Scriptlet.
I am getting value of some "Dataslot" from previous activity and now I want to perform some action on that "Dataslot" and display it in table. But I don't know how to get/use value of "Dataslot" inside scriptlet.
I should use request.getParameter() or jst.getDataSlotValue().
I tried both of them but I am not getting any error or output.
You need to get it from bean.getProp(String,Object,Boolean) based on the type of the dataslot in the JSP. You also need to add the dataslot as input to the BizSolo or Custom JSP you have added in the bizlogic process.
Also you need to define bean with com.savvion.BizSolo.beans.Bean and with scope as Session.

How to manually get/set object model from AngularDart component?

Angular manages our objects somewhere in the Scope, but I need to manually set and get the object that controls a component so I can automatically set all the component's info once I download its model from the web through JSON.
Example
#Component (selector: 'my-component')
class MyComponent {
//component fields
}
As the user interacts with <my-component> it changes its fields. I want to be able to get the whole MyComponent object with its fields to save them like this
MyComponent comp = magicComponentGetterFunc('my-component');
String json = encodeJson (comp); //I do this this redstone_mapper
I think ngProbe can do that.
ElementProbe ep = ngProbe('my-component');
You can can find examples by visiting the links at https://pub.dartlang.org/packages/angular where ngProbe or ElementProbe is mentioned.
The CHANGELOG.md mentions that ngProbe is necessary for animation but the codedoc on the ElementProbe class still states that it is for testing and debugging (see https://github.com/angular/angular.dart/blob/96c0bcc7b6b0c3501b2c4799f425de8cd2e4dc0c/lib/core_dom/view_factory.dart#L259)
To get the JSON you either have to implement a getter/method (for example toJson) that returns the JSON you want or use some of the available serialization solutions (see State of Serialization and Deserialization of JSON in Dart).
If you want to do that this usually indicates that your approach works against the way Angular should be used.

smart gwt save list as attribute

Hello i am new in smart gwt and now we are migrate from smartgwt 2.1 to smart gwt 3.1p
and i have got problem :
java.lang.UnsupportedOperationException: Can not convert element 0 of
the array to a JavaScriptObject. Instances of class
`com.test.ListDTO'
can not automatically be converted. Please see the SmartClient
documentation of RPCRequest.data for a table of Java types that can be
converted automatically.
someone write :
treeNode.setAttribute(TODO, listDTO.getLis());
how i can fix that code ?
The setAttribute method of the TreeNode tries to convert the list elements internally. That fails with your own domain objects. You can try to set the list with this helper method:
com.smartgwt.client.util.JSOHelper.setObjectAttribute(treeNode.getJsObj(), TODO, listDTO.getLis());
Now the Java object is set on the JavaScriptObject. To get this object back you can call:
treeNode.getAttributeAsObject(TODO);

PrimeFaces: How do I declare and bind an AJAX "rowEdit" event to p:dataTable programmatically?

I'm still developing my data table UI application, and finally I'm about the final stage of the development of this component: inline cell editing.
First of all, the data table is built fully dynamically at the Java side, and no facelet declarations are used to describe the table. If I'd have a static table declaration, the editing could be specified like this (see the In-Cell Editing chapter):
<p:dataTable>
...
<p:ajax event="rowEdit" listener="#{tableBean.onEdit}"/>
...
</p:dataTable>
I can easily specify the data table editable with dataTable.setEditable(true) in the Java code - and it works, please note, the editing Save/Cancel icons are working nice but have no effect at the back end. Since I cannot it declare in the way specified at the PF ShowCase Labs page (must I always use the listeners there?) because of the data tables are rendered dynamically, I'm trying to use the following:
public static AjaxBehavior createAjaxBehavior(MethodExpression expression) {
final AjaxBehavior behavior = new AjaxBehavior();
behavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(expression));
return behavior;
}
...
dataTable.addClientBehavior("rowEdit", createAjaxBehavior(createMethodExpression(TableBean.class, "onEdit", void.class, new Class<?>[] {RowEditEvent.class})));
But as soon as I add the rowEdit listener, like I'm trying to do above, and wow I suddenly got: mojarra is not defined and no Save/Cancel row edit buttons are working. Ok, I've found a similar problem described and resolved here, included the necessary script manually, and now the client-side JavaScript error is gone, however I still cannot exit the row editing mode, and the row is still not updated.
I wasted all day trying to figure out what's going on, and I'm blind to see the correct way. Do I simply miss something behind (like identifying a certain row, or probably specifying something else somewhere -- but my Java code does not generate anything more than specified in the PF example), or anything whatever?
Thanks in advance.
Well, I've just figured out the real reason in the following method:
public static AjaxBehavior createAjaxBehavior(MethodExpression expression) {
final AjaxBehavior behavior = new AjaxBehavior();
behavior.addAjaxBehaviorListener(new AjaxBehaviorListenerImpl(expression));
return behavior;
}
In fact, the method actually returned javax.faces.component.behavior.AjaxBehavior (h:ajax?) instead of org.primefaces.component.behavior.ajax.AjaxBehavior (p:ajax) -- this happened because of quick auto-complete so I simply missed that fact.
I'm frustrated that the PrimeFaces library didn't reply any error.
Just to complete the Q & A:
Mojarra 2.1.7
PrimeFaces 3.2
Should now (at least for PF 6.0) be org.primefaces.behavior.ajax.AjaxBehavior.

Resources