[JBoss Seam] - Polimorphism problem :(
by przemjaskier
** Problem: I cannot customize content of a template, depending on a type of returned hibernate @Entity.
** Environment: MyFaces 1.1.4, Facelets 1.1.12, Seam 1.1.6, Hibernate 3.2.1.
** Situation:
I have three Hibernate entities:
1. Item - annotated with @Inheritance(strategy=InheritanceType.SINGLE_TABLE), @DiscriminatorColumn, @DiscriminatorValue, @Entity
public void getProperty();
isExtendedFlagSet(); //returning true only when this is instance of
//ExtendedItem below (I need such flags in
//general)
2. ExtendedItem extends Item - annotated with @DiscriminatorValue, @Entity
public void getExtendedProperty();
3. ItemHolder - annotated with @Entity
Item getItem();
And an EVENT scope backer:
currentItemProvider getting ItemHolder proxies/instances from Hibernate.
And two jsf+facelets templates, which I want to render different in case when ItemHolder.getItem()
returns instance if ExtendedItem than when it returns instance of Item.
** My (not working completely) solution:
Using custom, render-time-if component, which renders children when "currentItemProvider.itemholder.item.extendedFlagSet" is true,
enable fragment of page:
<h:outputText value="#{currentItemProvider.itemholder.item.property}"/>
<mycomp:renderTimeIf condition="#{currentItemProvider.itemholder.item.extendedFlagSet}">
<h:outputText value="#{currentItemProvider.itemholder.item.extendedProperty}"/>
</mycomp:renderTimeIf>
1. WORKS OK, when placed in a render-time loop of ui:repeat. Different item appear
on a page rendered according to their isExtendedFlagSet value
2. But DOESN'T work when put in compile-time ui:decorate or direct in a template. I get:
SEVERE: Error Rendering View[/itemDetails.xhtml]
javax.faces.el.PropertyNotFoundException: /WEB-INF/templates/itemtemplate.xhtml @18,132 value="#{currentItemProvider.itemholder.item.extendedProperty}":
Bean: package.Item$$EnhancerByCGLIB$$b215fa4e, property: extendedProperty
at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
at org.apache.myfaces.shared_impl.renderkit.RendererUtils.getStringValue(RendererUtils.java:217)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.renderOutput(HtmlTextRendererBase.java:69)
at org.apache.myfaces.shared_impl.renderkit.html.HtmlTextRendererBase.encodeEnd(HtmlTextRendererBase.java:57)
at javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:536)
** Question: how to deal with such instance-dependent customization? I have a huge, complex domain (above is only a simplified illustration)
and would gladly stay with this consistent isFlasSet() approach, but if it should be done in a different way, please suggest.
Regards,
Przemek
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016291#4016291
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016291
19Â years, 2Â months
[EJB/JBoss] - Problem with the REQUIRED transaction attribute
by warx
Hello everybody,
i have a problem, the application I am working on.
The database access is managed by Session EJB.
So, if the user needs some data He/She calls a method of a Session EJB which calls some DAO and returns to the user a Collection of data.
The application worked well until some users started to use it a alot.
So, the situatio is :
- An user A calls a method of the Session EJB which calls some DAO to
perform some SELECT queries on the table TEST
- While the user A is doing its job an user B calls a method of the same
Session EJB to perform an INSERT query on the table TEST
The result is that the table TEST has a DEADLOCK, because it seems that the method which performs the SELECT queries LOCKS the table TEST.
We have this kind of behavoiur because every method of the Session EJB is marked as Transaction REQUIRED.
So, what is the right transaction attribute to specify on the methods of the Session EJB for not to generate the DEADLOCK problem ?
Any suggestion ?
Cheers.
Stefano
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016279#4016279
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016279
19Â years, 2Â months
[EJB/JBoss] - Problm while calling EJB
by murthy_j2ee
Hi Everybody,
I am new to deploy EJB in JBOSS Application Server. I am succeeded to run configur JAAS in my JBOSS and abeled to run
it successfully. I have created my own Login Module and abled to authenticate it successfully by retreving the username and
password from database using. Now i want to call an ejb from login module instead of calling database directly. When i am
calling the Remote Ejb to get the instance of EjbBean i am getting the exception like Insufficient method permissions,
principal=null, ejbName=UserAuthentication_Session, method=create, interface=HOME, requiredRoles=[], principalRoles=[]
Here is the configurations in xml files....
ejb-jar.xml
<ejb-jar >
<enterprise-beans>
UserAuthentication_Session
<ejb-name>UserAuthentication_Session</ejb-name>
com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_SessionHome
com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_Session
<ejb-class>com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_SessionBean</ejb-class>
<session-type>Stateless</session-type>
<transaction-type>Bean</transaction-type>
</enterprise-beans>
</ejb-jar>
-----------------------------------------
jboss-web.xml
<jboss-web>
<ejb-ref>
<ejb-ref-name>UserAuthentication_Session</ejb-ref-name>
<jndi-name>UserAuthentication_Session</jndi-name>
</ejb-ref>
</jboss-web>
--------------------------------------
jboss.xml
<enterprise-beans>
<ejb-name>UserAuthentication_Session</ejb-name>
<jndi-name>UserAuthentication_Session</jndi-name>
</enterprise-beans>
<resource-managers>
</resource-managers>
---------------------------------------------------
web.xml
<web-app>
<ejb-ref>
<ejb-ref-name>UserAuthentication_Session</ejb-ref-name>
<ejb-ref-type>This is SESSION </ejb-ref-type>
com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_SessionHome
com.prospecta.WSOProject.User_Authentication.ejb.UserAuthentication_Session
<ejb-link>UserAuthentication_Session</ejb-link>
</ejb-ref>
</web-app>
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4016278#4016278
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4016278
19Â years, 2Â months