[JBoss Seam] - Re: Error in Hibernate Filter With Multiple Entities
by pourmo
Hi christian
You are correct the code above is not exactly the code from wiki, but on the similar implementation. We think we have found the source of the problem.
If the FilterredQueries are Not implemented correctly and I pass multiple entities to createFullTextQuery, my entitymanager will return everyting regardless of access level.
If the FilterredQueries are Not implemented correctly and I pass signle entities to createFullTextQuery, FullTextQuery will return results, but the entitymanager will apply the access level filtering.
We found that our FilteredQuery is not working so we replaced it with TermQuery, However we like to know as to why the above senario has happend, my guess is that If FullTextQuery returns records of different entities, the entitymanager is unable to filter them.
cheers
Mo
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098646#4098646
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098646
18Â years, 8Â months
[JBoss Seam] - Re: selectItems - Is it possible?
by Kragoth
1
No stack trace is given. The error message is from a h:messages component.
2
Seam 2.0.0CR2
JSF 1.2
3
I'm not entirely sure what I need to do regards Stateful / Stateless for this bean.
Another slightly smaller issue is that it does not select the "no Selection" item as default. I would like this to be the case. Any ideas on that?
I have created a somewhat working version by using the following.
The xhtml file:
| <!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:ui="http://java.sun.com/jsf/facelets"
| xmlns:h="http://java.sun.com/jsf/html"
| xmlns:f="http://java.sun.com/jsf/core"
| xmlns:rich="http://richfaces.org/rich"
| xmlns:a4j="https://ajax4jsf.dev.java.net/ajax"
| xmlns:s="http://jboss.com/products/seam/taglib"
| xmlns:j4j="http://javascript4jsf.dev.java.net/"
| xmlns:gekko="http://gekkoTagLibs.com">
|
| <head></head>
| <body>
| <h:form id="searchCriteria" >
| <rich:panel>
| <f:facet name="header">
| <h:outputText value="Factor for Category/Subcategory Enquiry (TLONL999)"></h:outputText>
| </f:facet>
|
| <rich:panel>
| <h:messages globalOnly="true"/>
| </rich:panel>
|
| <h:panelGrid columns="3">
| <h:outputText value="Category:" styleClass="inputLabel"></h:outputText>
| <h:selectOneMenu id="categoryFilter" value="#{catSubcatEnquiryActionBean.categoryCode}" converter="gekkoGenericObjectConverter">
| <s:selectItems value="#{categories}" var="category" noSelectionLabel="none"
| label="#{category.name}"/>
| </h:selectOneMenu>
| <h:message for="categoryFilter"></h:message>
| <h:outputText value="Subcategory:" styleClass="inputLabel"></h:outputText>
| <h:selectOneListbox id="subcategoryFilter">
| </h:selectOneListbox>
| <h:message for="subcategoryFilter"></h:message>
| <h:outputText value="Date:" styleClass="inputLabel"></h:outputText>
| <rich:calendar id="calendarFilter"
| showInput="true"
| enableManualInput="true"
| datePattern="#{catSubcatEnquiryActionBean.dateFormat}"
| currentDate="#{catSubcatEnquiryActionBean.currentDate}"
| value="#{catSubcatEnquiryActionBean.dateFilter}"
| converter="gekkoDateConverter"
| >
| </rich:calendar>
| <h:message id="calendarErrors" for="calendarFilter"></h:message>
| </h:panelGrid>
|
| </rich:panel>
|
| <h:commandButton id="formSubmit" type="submit" value="Search" action="#{catSubcatEnquiryActionBean.doSearch}">
| <gekko:defaultAction/>
| </h:commandButton>
|
| </h:form>
|
| </body>
| </html>
|
The converter
| package gekko.web.converter;
|
| import gekko.domain.PersistentEntity;
| import gekko.domain.reference.ltl.CategoryCode;
|
| import javax.faces.component.UIComponent;
| import javax.faces.context.FacesContext;
| import javax.faces.convert.Converter;
| import javax.faces.convert.ConverterException;
|
| import com.sun.faces.util.MessageFactory;
|
| import org.jboss.seam.jsf.ListDataModel;
|
| public class GenericObjectConverter implements Converter {
|
| /**
| * <p>The standard converter id for this converter.</p>
| */
| public static final String CONVERTER_ID = "gekko.web.converter.GenericObjectConverter";
|
| /**
| * <p>The message identifier of the {@link javax.faces.application.FacesMessage} to be created if
| * the conversion to <code>Date</code> fails. The message format
| * string for this message may optionally include the following
| * placeholders:
| * <ul>
| * <li><code>{0}</code> replaced by a <code>String</code> whose value
| * is the label of the input component that produced this message.</li>
| * </ul></p>
| */
| public static final String NO_CLASS_SPECIFIED =
| "gekko.web.converter.GenericObjectConverter.NOCLASS";
|
| /**
| * <p>The message identifier of the {@link javax.faces.application.FacesMessage} to be created if
| * the conversion of the <code>DateTime</code> value to
| * <code>String</code> fails. The message format string for this message
| * may optionally include the following placeholders:
| * <ul>
| * <li><code>{0}</code> replaced by a <code>String</code> whose value
| * is the label of the input component that produced this message.</li>
| * </ul></p>
| */
| public static final String INVALID_CLASS =
| "gekko.web.converter.GenericObjectConverter.INVALIDCLASS";
|
| @Override
| public Object getAsObject(FacesContext context, UIComponent component,
| String value) {
|
| try {
|
| for(UIComponent comp : component.getChildren()) {
|
| ListDataModel objectList = (ListDataModel)comp.getValueExpression("value").getValue(context.getELContext());
| objectList.setRowIndex(0);
| while (objectList.isRowAvailable()) {
| CategoryCode currentCategory = (CategoryCode)objectList.getRowData();
| if (currentCategory.getId().toString().equals(value)) {
| return currentCategory;
| }
| objectList.setRowIndex(objectList.getRowIndex() + 1);
| }
| }
| } catch (ConverterException e) { // NOPMD
| throw e;
| } catch (Exception e) {
| throw new ConverterException(e);
| }
|
| return null;
| }
|
| @Override
| public String getAsString(FacesContext context, UIComponent component,
| Object value) {
|
| String id;
|
| try {
|
| if (value == null) {
| return "";
| }
|
| id = ((PersistentEntity)value).getId().toString();
| return id;
|
| } catch (ConverterException e) {
| throw new ConverterException(MessageFactory.getMessage(
| context, INVALID_CLASS,
| MessageFactory.getLabel(context, component)), e);
| } catch (Exception e) {
| throw new ConverterException(MessageFactory.getMessage(
| context, INVALID_CLASS,
| MessageFactory.getLabel(context, component)), e);
| }
| }
|
| }
|
This actually works and updates my bean etc etc... so I will use this if there are no better solutions. I will look into this Stateful idea and see what affect that has.
But I would REALLY like it if I could make the noSelectionLabel the default selection in the selectOneMenu
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4098640#4098640
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4098640
18Â years, 8Â months