[JBoss Seam] - DataModel using Set does not work
by andreigh.ts
Hi,
I am trying to use java.util.Set as a @DataModel but it throws an exception (javax.faces.el.PropertyNotFoundException .... Bean: org.hibernate.collection.PersistentSet) when trying to display the xhtml.
Replacing Set with List or array works very well.
Here is the code:
The Hibernate Entity bean that initially holds the set:
| @Entity
| @Table(name = "RFQ_Request", uniqueConstraints = {})
| public class RfqRequest implements java.io.Serializable {
| ...
| private Set<RfqRequestQuestion> rfqRequestQuestions = new HashSet<RfqRequestQuestion>(0);
| ...
| }
|
One element of the Set looks like this:
| @Entity
| @Table(name = "RFQ_Question", uniqueConstraints = {})
| public class RfqQuestion implements java.io.Serializable {
| ...
| @Column(name = "Description", unique = false, nullable = false, insertable = true, updatable = true)
| public String getDescription() {
| return this.description;
| }
| ...
| }
|
A seam component that should expose the DataModel:
| @Stateless
| @Name("requestWizardQuestions")
| public class RequestWizardQuestionsAction implements RequestWizardQuestions {
| @In(required=false, scope=ScopeType.CONVERSATION)
| @Out(required=false, scope=ScopeType.CONVERSATION)
| private RfqRequest rfqRequest;
|
| @DataModel
| public Set<RfqRequestQuestion> getRfqQuestions() {
| return rfqRequest.getRfqRequestQuestions();
| }
|
| @DataModelSelection
| private RfqRequestQuestion selectedQuestion;
| }
|
And the page that should display the DataModel:
| ...
| <h:dataTable var="question" value="#{requestWizardQuestions.rfqQuestions}" >
| <h:column>
| <f:facet name="header">
| <h:outputText value="Question"/>
| </f:facet>
| <h:outputText value="#{question.description}"/>
| </h:column>
| </h:dataTable>
| ...
|
This throws this exception when trying to display the page:
| javax.faces.el.PropertyNotFoundException: /requestWizard/questions.xhtml @24,59
| value="#{question.description}": Bean: org.hibernate.collection.PersistentSet, property: description
| at com.sun.facelets.el.LegacyValueBinding.getValue(LegacyValueBinding.java:58)
| at javax.faces.component.UIOutput.getValue(UIOutput.java:77)
| .......
|
If I change the @DataModel and replace the Set < RfqQuestion > with RfqQuestion[]. it works.
What is wrong?
Thanks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054043#4054043
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054043
18Â years, 11Â months
[JBoss Seam] - Re: Can't set Character encoding for submitted form data
by atao
The only thing you really need is
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
as stated previously. It is always used by the browser to sent request to the server. Even if the encoding option of the browser is forced to an other value.
The attribut "lang" in tag "html" is not related to the charset but to the presentation options for date, currency, number...
I've never had any problem with english/french applications. I let the browser and server switch between the two of them. I don't use any CharacterEncodingFilter. At least it must be used without "overrideClient" parameter unless you're sure at 100% that all the pages sent to the browser are in the same charset that the one specified.
The last time I got such issue, it was related to a database server which was configured with a charset different of the one specified in the web pages.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054042#4054042
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054042
18Â years, 11Â months
[JBoss Seam] - Conversations - do not work in Seam 1.2.1?
by bsmithjj
I'm working on some code where I am trying to do the following:
1. User clicks a link to an action method on a SFSB
2. method is annotated with @Begin, using a custom conversation id
2a. the custom conversation id comes from the following
2a-1. a @Factory method in a SLSB creates a new persistent entity; the id of this entity will be appended to a String to create a custom conversation id
2a-2. the @Factory class would like to use the existing persistent entity if possible (avoid creating new persistent or querying for existing persistent entity) - thus, I have an @In for the entity.
2a-3. here is the class with the @Factory method:
| @Stateless
| @Name("draftAccessRequestFinder")
| public class DraftAccessRequestFinderBean implements DraftAccessRequestFinder {
|
| @Logger
| private Log log;
|
| @PersistenceContext(unitName = "accessControlDatabase")
| private EntityManager em;
|
| @In
| private Principal userPrincipal;
|
| @In("#{conversation.id}")
| private String conversationId;
|
| @In(required = false) @Out(scope= ScopeType.CONVERSATION)
| private DraftAccessRequestMaster draftAccessRequestMaster;
|
| @Factory("draftAccessRequestMaster")
| public DraftAccessRequestMaster createMaster() {
| log.info("DraftAccessRequestFinderBean.createMaster() : conversationId -> "+conversationId);
| log.info("DraftAccessRequestFinderBean.createMaster() : draftAccessRequestMaster -> "+draftAccessRequestMaster);
| // create or load draftAccessRequest....
| if (conversationId != null && conversationId.indexOf(':')>0 && draftAccessRequestMaster == null) {
| long id = Long.valueOf(conversationId.substring(conversationId.indexOf(':')+1));
| draftAccessRequestMaster = em.find(
| DraftAccessRequestMaster.class, id
| );
| log.info("loaded draftAccessRequestMaster -> "+draftAccessRequestMaster);
| }
|
| if (draftAccessRequestMaster == null) {
| if (userPrincipal == null) {
| throw new RuntimeException("userPrincipal is null.");
| }
| if (!(userPrincipal instanceof UserPrincipal)) {
| throw new RuntimeException("userPrincipal is not an instance of com.evergreen.jaas.UserPrincipal.");
| }
| draftAccessRequestMaster = new DraftAccessRequestMaster();
| draftAccessRequestMaster.setUserId(
| ((UserPrincipal) userPrincipal).getUserid()
| );
| draftAccessRequestMaster.setUserName(
| ((UserPrincipal) userPrincipal).getPersonName()
| );
| em.persist(draftAccessRequestMaster);
| em.flush(); // we need to obtain a PK for this entity now...
| }
| return draftAccessRequestMaster;
| }
| }
|
3. here is the SFSB that wants the custom conversation id as well as a reference to the persistent entity:
| @Stateful
| // Seam - defaults to Conversational context...
| @Name("accessRequestManager2")
| public class AccessRequestManager2Bean implements AccessRequestManager2 {
|
| @Logger
| private Log log;
|
| @PersistenceContext(unitName = "accessControlDatabase")
| private EntityManager em;
|
| @In
| private UserPrincipal userPrincipal;
|
| // for development purposes only - todo remove this
| @In
| private Conversation conversation;
|
| @In(create=true) @Out(scope= ScopeType.CONVERSATION)
| private DraftAccessRequestMaster draftAccessRequestMaster;
|
| @Out
| private List<String> errors = new ArrayList<String>();
|
|
| /**
| * Start a new add-access request. This method also generates the conversationId to
| * use in the conversation that beans of this class are associated with.
| *
| * This is complicated - in 1 swoop, we need to
| * 1 - create the DraftAccessRequestMaster for the conversation component
| * 2 -
| */
| @Begin(id = "DraftAccessRequestID:#{draftAccessRequestMaster.id}", join = true)
| public void startAddRequest() {
| log.info("startAddRequest()");
| log.info(conversation);
| log.info("conversation.id = " + conversation.getId());
| log.info("conversation.parentId = " + conversation.getParentId());
|
| if (draftAccessRequestMaster == null) {
| log.info("draftAccessRequestMaster is null...not expected.");
| }
| ....
| }
| }
|
4. here is a link that calls the SFSB method:
| <s:link action="#{accessRequestManager2.startAddRequest}" value="Add 2"
| title="Add entitlements to an application for a user.">
| </s:link>
|
5. and here is a log of what occurs
| First click of link...
|
| 10:53:32,805 INFO com.evergreen.accesscontrol.impl.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() : conversationId -> 3
| 10:53:32,805 INFO com.evergreen.accesscontrol.impl.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() : draftAccessRequestMaster -> null
| 10:53:32,805 INFO com.evergreen.accesscontrol.entity.DraftAccessRequestMaster - new DraftAccessRequestMaster()
| 10:53:32,821 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - startAddRequest()
| 10:53:32,821 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - org.jboss.seam.core.Conversation@54d3dd
| 10:53:32,821 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - conversation.id = DraftAccessRequestID:50
| 10:53:32,821 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - conversation.parentId = null
|
| Second click of link (expecting to find draftAccessRequestMaster in memory for conversation but it's not found...)
|
| 10:53:36,915 INFO com.evergreen.accesscontrol.impl.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() : conversationId -> DraftAccessRequestID:50
| 10:53:36,915 INFO com.evergreen.accesscontrol.impl.DraftAccessRequestFinderBean - DraftAccessRequestFinderBean.createMaster() : draftAccessRequestMaster -> null
| 10:53:36,930 INFO com.evergreen.accesscontrol.entity.DraftAccessRequestMaster - new DraftAccessRequestMaster()
| 10:53:36,930 INFO com.evergreen.accesscontrol.impl.DraftAccessRequestFinderBean - loaded draftAccessRequestMaster -> DraftAccessRequestMaster{...}
| 10:53:36,930 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - startAddRequest()
| 10:53:36,930 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - org.jboss.seam.core.Conversation@adf2c7
| 10:53:36,946 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - conversation.id = DraftAccessRequestID:50
| 10:53:36,946 INFO com.evergreen.accesscontrol.impl.AccessRequestManager2Bean - conversation.parentId = null
|
So note that I @Out(ject) the entity to Conversation scope, however, when the link is clicked the second time the SLSB and the SFSB don't have an instance of draftAccessRequestMaster injected. So why can't I find my conversational-scoped entity? It looks like the conversation is correctly @Begin(ning) or joining based on whether or not the conversation exists.
Thanks,
Brad Smith
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054036#4054036
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054036
18Â years, 11Â months
[JBoss Portal] - org.jboss.portal.core.model.portal.Context missing ??
by ghyoju
Hi
There used to be org.jboss.portal.core.model.portal.Context in JBOSS Portal 2.4.1, according to the javadoc it should also be in JBOSS Protal 2.6 http://docs.jboss.com/jbportal/v2.6/javadoc/org/jboss/portal/core/model/p... but it is not there (am I missing something?).
I am trying to get the portal names from the JBOSS Portal. I was able to do it in 2.4.1 with following code :
| TransactionManager tm = null;
| try {
| InitialContext ic = new InitialContext();
| tm = (TransactionManager) ic.lookup("java:/TransactionManager");
| } catch (NamingException ex) {
| System.out.println("Failed to find transactionmnager" );
| }
|
| try
| {
| tm.begin();
| try {
| PortalObjectContainer container;
| container = (PortalObjectContainer)getPortletContext().getAttribute("PortalObjectContainer");
| Context context = container.getContext();
|
| Iterator portalObjectIterator= context.getChildren().iterator();
|
| ArrayList names = new ArrayList();
|
| while (portalObjectIterator.hasNext())
| {
| PortalObject child = (PortalObject) portalObjectIterator.next();
| String name = child.getName();
| names.add(name);
| }
| }
| finally {
| tm.commit();
| }
| }
| catch ( Exception ex ) {
| ex.printStackTrace();
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4054030#4054030
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4054030
18Â years, 11Â months