[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-3988) Support for mapping RESTful XHTML resource representations with Facelets templates
by Christian Bauer (JIRA)
Support for mapping RESTful XHTML resource representations with Facelets templates
----------------------------------------------------------------------------------
Key: JBSEAM-3988
URL: https://jira.jboss.org/jira/browse/JBSEAM-3988
Project: Seam
Issue Type: Feature Request
Components: WS
Reporter: Christian Bauer
Assignee: Jozef Hartinger
What I wrote a while ago about this feature:
I'm thinking about a special provider that can marshal an object graph into an XHTML (not just XML) response body and back from an XHTML request body to an object graph. This is about the "connectedness" of resources, see the O'Reilly REST book. As a developer I should write a Facelets XHTML template that defines the transformation. Imagine that you write it the same way you write a JSF template today, with bidirectional binding using EL expressions, from object getter/setter pair to XML attribute or element value. We can even have built-in Facelets "widgets" that render certain microformats. Seam has some machinery for this already but we might need an extra interceptor on resource methods to trigger the transformation. Or we use Seams pages.xml navigation rules ("when this resource method finishes, render this template").
Later I did some prototype experiments - note that this only considers uni-directional mapping for GET, handling POST/PUT resource representation is more difficult:
package org.jboss.seam.resteasy;
import java.lang.annotation.*;
/**
* @author Christian Bauer
*/
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
public @interface FaceletsXhtmlResponse {
String template();
}
package org.jboss.seam.resteasy;
import org.jboss.seam.core.Interpolator;
import org.jboss.seam.faces.Renderer;
import org.jboss.seam.log.Log;
import org.jboss.seam.log.Logging;
import javax.ws.rs.ProduceMime;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.ext.MessageBodyWriter;
import javax.ws.rs.ext.Provider;
import java.io.IOException;
import java.io.OutputStream;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
/**
* @author Christian Bauer
*/
@Provider
@ProduceMime("application/xhtml+xml")
public class FaceletsXhtmlProvider implements MessageBodyWriter<Object> {
Log log = Logging.getLog(FaceletsXhtmlProvider.class);
public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations) {
for (Annotation annotation : annotations) {
if (annotation.annotationType().equals(FaceletsXhtmlResponse.class)) {
return true;
}
}
return false;
}
public long getSize(Object o) {
return -1;
}
public void writeTo(Object o, Class<?> type, Type genericType, Annotation[] annotations,
MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
throws IOException {
log.debug("writing XHTML response for entity type: " + type.getName());
FaceletsXhtmlResponse respAnnotation = null;
for (Annotation annotation : annotations) {
if (annotation.annotationType().equals(FaceletsXhtmlResponse.class))
respAnnotation = (FaceletsXhtmlResponse) annotation;
}
if (respAnnotation == null) throw new IllegalStateException("@FaceletsXhtmlResponse annotation disappeared");
String template = getTemplatePath(respAnnotation);
log.debug("rendering XHTML template: " + template);
String output = Renderer.instance().render(template);
entityStream.write(output.getBytes());
}
protected String getTemplatePath(FaceletsXhtmlResponse annotation) {
return isTemplatePathInterpolated()
? Interpolator.instance().interpolate(annotation.template())
: annotation.template();
}
protected boolean isTemplatePathInterpolated() {
return true;
}
}
@Name("customerResource")
@Path("/customer")
public class CustomerResource {
@GET
@ProduceMime("application/xhtml+xml")
@FaceletsXhtmlResponse(
template = "#{somePath}/customerTemplate.xhtml"
)
@Out(value = "customers", scope = ScopeType.EVENT)
public List<Customer> getCustomers() {
return mockCustomers();
}
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:t="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core">
<head>
<title>Customers</title>
</head>
<body>
<ul>
<t:repeat var="cust" value="#{customers}">
<li>
<h:outputText value="#{cust.name}"/>
</li>
</t:repeat>
</ul>
</body>
</html>
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 11 months
[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-3703) bug in JbpmElResolver
by Gergely Nagy (JIRA)
bug in JbpmElResolver
---------------------
Key: JBSEAM-3703
URL: https://jira.jboss.org/jira/browse/JBSEAM-3703
Project: Seam
Issue Type: Bug
Components: BPM
Reporter: Gergely Nagy
I could not pass a jbpm context variable to a seam component. I'm using seam 2.0.2.SP1, but the same code is still present in trunk. I tracked down the bug to the following method in class org.jboss.seam.bpm.JbpmELResolver
public Object getValue(ELContext context, Object base, Object property)
{
if ( base==null && property!=null )
{
return resolver.resolveVariable( (String) base );
}
else
{
return null;
}
}
note that base is passed into resolveVariable instead of property. I think it should be property. also, the isResolved property of ELContext is not set to true.
If i manually set these two values in a debugging session, the code worked as expected.
Proposed fix:
public Object getValue(ELContext context, Object base, Object property)
{
if ( base==null && property!=null )
{
context.setPropertyResolved(true);
return resolver.resolveVariable( (String) property );
}
else
{
return null;
}
}
A bit more context:
I had this in my workflow description:
<task-node name="importanttask">
<task name="justdoit">
<assignment pooled-actors="#seamcomponent.getActor(taskInstance)}"/>
</task>
<transition to="nextstep" name="donext"/>
</task-node>
Without the above fix, the getActor() method on seamcomponent is called with null, with the fix i get passed in the actual task instance.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
14 years, 11 months
[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-1814) DataModel wrapped data is set to null by ManagedEntityIdentityInterceptor
by Matt Drees (JIRA)
DataModel wrapped data is set to null by ManagedEntityIdentityInterceptor
-------------------------------------------------------------------------
Key: JBSEAM-1814
URL: http://jira.jboss.com/jira/browse/JBSEAM-1814
Project: JBoss Seam
Issue Type: Bug
Affects Versions: 2.0.0.BETA1
Environment: seam cvs (20070816.1709)
Reporter: Matt Drees
Priority: Minor
The following test fails:
@Name("dataModelComponent")
@Scope(ScopeType.CONVERSATION)
public class DataModelComponent extends EntityQuery {
@Override
public String getEjbql() {
return "from java.lang.Object o";
}
}
public class DataModelComponentTest extends SeamTest{
@Test
public void test() throws Exception {
new FacesRequest() {
@Override
protected void renderResponse() throws Exception {
DataModel model = (DataModel) getValue("#{dataModelComponent.dataModel}");
assert model.getWrappedData() != null;
}
}.run();
}
}
Because the component is conversation-scoped, a ManagedEntityIdentityInterceptor is attached, which nulls the wrapped List after getDataModel() is called.
In the referenced forum, Gavin indicated he hadn't decided whether this should be expected behavior or not, and asked for a jira issue.
If it is expected behavior (I hope not), I think either EntityQuery should not have a getDataModel() attribute, or it should be documented and/or programmatically enforced that EntityQuerys should not be conversation-scoped.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-3991) Asynchronous HTTP support in Seam+RESTeasy
by Balazs Pataki (JIRA)
Asynchronous HTTP support in Seam+RESTeasy
------------------------------------------
Key: JBSEAM-3991
URL: https://jira.jboss.org/jira/browse/JBSEAM-3991
Project: Seam
Issue Type: Feature Request
Components: WS
Affects Versions: 2.1.1.GA
Reporter: Balazs Pataki
Fix For: 2.1.2.CR1
There should be support for handling asynchronous HTTP connections in a way similar to the plain RESTeasy solution:
http://www.jboss.org/file-access/default/members/resteasy/freezone/docs/1...
It actually seems very straightforward to implement it in Seam, the only problem is that there needs to be 3 different implementations for Tomcat6+JBoss 4.2.x, JBoss 5, and Servlet 3. At least, in RESTeasy it is implemented this way.
For me I took the Tomcat6+JBoss 4.2.x implementation of org.jboss.resteasy.plugins.server.servlet.Tomcat6CometDispatcherServlet and based on this I added "implements CometProcessor" to ResteasyDispatcher + copied the event() and createHttpRequest() methods over from Tomcat6CometDispatcherServlet . Then I also added ResteasyAsyncHttpRequest, which is a clone of org.jboss.resteasy.plugins.server.servlet.Tomcat6AsyncHttpRequest. With this setup plus adding the
<Connector port="8080" address="${jboss.bind.address}"
emptySessionPath="true" protocol="org.apache.coyote.http11.Http11NioProtocol"
enableLookups="false" redirectPort="6443" acceptorThreadCount="2" pollerThreadCount="10"
/>
connector instead of the vanilla one to JBOSS_HOME/server/default/deploy/jboss-web.deployer/server.xml seem to make it all work form me.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://jira.jboss.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years
[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-2678) improve docs for conversation propagation
by Martin Trummer (JIRA)
improve docs for conversation propagation
-----------------------------------------
Key: JBSEAM-2678
URL: http://jira.jboss.com/jira/browse/JBSEAM-2678
Project: JBoss Seam
Issue Type: Feature Request
Components: Documentation Issues
Environment: n.A.
Reporter: Martin Trummer
following points should be emphasized in the docs:
* the fact, that ending a conversation demotes the long-running conversation to a temporary conversation should be emphasized in the docs or explained in more detail
* the difference between ending a conversation and ending a conversation before-redirect should also be explained in more detail
* the docs should mention, that any facesMessages are lost, when you end the conversation and use before-redirect=true (and maybe how to work around this)
discussion can be found in the forum
I will attach a text file with a draft, of what these improvements could be (hope this helps)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
15 years