quinta-feira, 29 de agosto de 2013

Primepush



One socket to listener the channel and call the javascript function.
<p:socket onMessage="functionName" channel="/notifyTreeMap"  />


The tag remmote command can be used to
<h:form>
          <p:remoteCommand id="test" name="functionName" actionListener="" update="" global="false" />        
 </h:form>

In Menaged Bean,  get context by;
PushContext pushContext = PushContextFactory.getDefault().getPushContext();



To use primepush in jboss the atmosphere dependence is needed.

  <dependency>
            <groupId>org.atmosphere.jboss.as</groupId>
            <artifactId>jboss-as-websockets</artifactId>
            <version>0.5</version>
   </dependency>

sábado, 24 de agosto de 2013

EJB3.1


EJB is used to provide services for distributed applications.
Some different configuration type can be used, one example in the code;

@Stateless //State type for the EJB
@LocalBean //Says that this need not local interface
public class Implementation   implements InterfaceRemote {
}

In this case the local method is all in the class Implementation, they don't need annotations.


Some implementations use generics to have less repeated code.
A Good use of  this is for DAO of entity, the class Implementation extends SomeGenericDAO<EntityTO>.
Or a simple use is extends SomeClass only.

One EJB can acess other using the annotation @EJB to inject dependen.
@EJB
private UserBean userBean;


This being updated.........

quinta-feira, 22 de agosto de 2013

Make client action from managed bean.


To add some message to client use addMessage from client session:

FacesContext.getCurrentInstance().addMessage(null, message);



The RequestContext can make some calls to Client side from bean.
RequestContext context = RequestContext.getCurrentInstance();

To execute some Javascript:
context.execute("Javascript_statement");



Example open new page;
String url;
context.execute("window.open('" + url + "', '_blank', 'location=no, status=no, menubar=no, toolbar=no, width=800, height=600')");

The RequestContext can update the client UI:
context.update("formSelectedElementOnMap");