We also think the class of applications we are targeting with jZeno only have a small number of cases where this is necessary.
In this example we'll create a component that allows an external web site to be visualized inside of a jZeno application. The HTML required to do this is extremely simple, we simple need to create an IFRAME. The example has been kept simple for didactical reasons, but you can readily imagine how this component could have more properties in a more realistic version. Basically you need to derive your component from CustomRenderingComponent.
In the example we implement 4 important functions :
- getHtml : This method must return a string containing the HTML rendering of the component.
- update : This method can be used to update the state of the component with information, sent from the browser.
It also imprtant to take a look at the setUrl() method. Specifically you need to add a similar firePropertyChange event to all of the properties that change the client side rendered component. The propertyChange event is detected by jZeno and is used to enlist your component to be re-rendered.
In order to send state updates from the client browser back to the server you need to do 2 things :
- A boolean indicating wether or not direct update is necessary. False will result in an update that is queued on the client browser until some other event triggers a roundtrip to the server. True will result in an immediate synchronisation with the server (POSTs updates to the server)
- Implement the update method to receive the (string) information that you have sent from the client and use it to update your component/trigger an event handler, etc... For triggering an event you should use the fireActionEvent() method, inherited from the baseclass.
Some more tips
- All CustomRenderingComponents are dynamic components and as such have data binding (get/setValue), dynamic event handling (fireActionEvent/setActionCommand/..), support for validation (addValidator/isValid/..), etc...
- Any property that you implement on your component must fire call the firePropertyChanged() method if that property affects the visual representation of the component. This is necessary to notify the rendering engine that re-rendering this component is necessary.If you forget to do this, you will experience situations where you component is not drawn correctly in the client's browser, but all of the logic in the code that uses your CustomRenderingComponent is correct.
|< Prev||Next >|