[jbossseam-issues] [JBoss JIRA] Created: (JBSEAM-2346) s:selectItems - noSelectionLabel is not hidden after first selection of a value
by Wolfgang Schwendt (JIRA)
s:selectItems - noSelectionLabel is not hidden after first selection of a value
-------------------------------------------------------------------------------
Key: JBSEAM-2346
URL: http://jira.jboss.com/jira/browse/JBSEAM-2346
Project: JBoss Seam
Issue Type: Bug
Environment: CVS-based Seam 2.0.1
Reporter: Wolfgang Schwendt
Priority: Minor
<s:selectItems> offers that the user can specify an (optional) "noSelectionLabel" to be placed at the top of the selection list. It further provides a hideNoSelectionLabel option -- if this property is true, the noSelectionLabel will be hidden when a value is selected.
And exactly the latter functionality has a bug, but only as far as the user's FIRST selection is concerned. When the users makes his _first_ selection and submits the form, then the noSelectionLabel is still displayed when the page is redisplayed by the server, no matter whether or not hideNoSelection was set to "true". However, when the users makes additional requests, the hideNoSelectionLabel functionality works correctly.
Reason for the bug: caching behavior of org.jboss.seam.ui.component.UISelectItems.getValue()
Too understand why there is a bug, consider the following scenario:
A page with <h:selectOneMenu> and <s:selectItems var="myVar" label="#{myVar.name}" value="#{resultList}" noSelectionLabel="* Your choice please *" hideNoSelectionLabel="true"/> as its child component.
When the user makes a selection and submits the form, the UISelectOne components checks during the "Process validations" JSF phase whether the submitted input value matches one of the available options (SelectItems). Consequently, the UISelectOne component calls the getValue() method of its org.jboss.seam.ui.component.UISelectItems child component in order to retrieve a list of SelectItem s. Then, if if validation was successful because a matching value was found, the user's selection is either written to the model (during JSF Update model phase) or if we don't make it to the Update model phase, because some other component had a validation error, the user's selection is stored in the value property of the UISelectOne component.
When we finally reach the "Render response" phase and the same page should be redisplayed, the UISelectOne component gets rendered again. In order to render the selection list items, org.jboss.seam.ui.component.UISelectItems.getValue() gets called another time.
But now it doesn't re-calculate its list of SelectItems. Take a look at the code:
org.jboss.seam.ui.component.UISelectItems.getValue()
@Override
public Object getValue()
{
if (value == null || originalValue == null || !originalValue.equals(super.getValue()))
{ ...
}
return value;
}
Note that "value" is not null, because during "Process validations" org.jboss.seam.ui.component.UISelectItems.getValue() was already called which lead to value being set. Therefore, getValue() returns the OLD cached list of SelectItem s, which was calculated during Process Validations and therefore still includes the noSelectionLabel! And therefore getValue() doesn't take into account that the user made a selection and that the noSelectionLabel should now be hidden.
--
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
14 years, 11 months
[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