[JBoss Seam] - Converter behavior PROBLEM
by urosmil
Hi,
I'm having problem with jsf converter behavior.
This is converter code:
public class OfferPriceConvertor implements Converter{
|
| public Object getAsObject(FacesContext arg0, UIComponent arg1, String string) {
| BigDecimal price = null;
| try {
| price = new BigDecimal( string );
| } catch (Exception e) {
| price = new BigDecimal(0);
| }
| return price;
| }
|
| public String getAsString(FacesContext arg0, UIComponent arg1, Object object) {
| BigDecimal price = (BigDecimal) object;
| BigDecimal minPrice = null;
| try {
| minPrice = new BigDecimal( GlobalProperties.getStaticData("minimum_offer_price") );
| } catch (Exception e) {
| minPrice = new BigDecimal(0);
| }
| return ((price != null && price.doubleValue() > 0) ? price.toPlainString() : minPrice.toPlainString());
| }
|
| }
Converter works ok when page is rendered.
Problem appears when page is submitted. Function "getAsObject" is executed BUT instead of entering action method I got same page displayed again.
There are probably some problem inside jsf lifecycle but I don't see anything in console.
These anyone had same problem?
I am interested in any suggestion.
Thanks,
Uros.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083452#4083452
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083452
18 years, 8 months
[EJB 3.0] - Returning an EJB from other
by francesquini
Hi!
I'd like to return an stateful EJB from another EJB to a client. Nothing new to it, but, I'd like to have it initialized before hand.
In earlier versions of EJB (as in 2.1) I could do that by declaring a create method with some parameters in a Home interface. Now, in EJB 3.0 I couldn't find a way to do it. I imagine the solution for that is to use the @Init annotation with a inicialization method that receveis some arguments. The problem is that I'm not sure how to make the container call this method because I don't realy know any other way to create an EJB instance other than doing a JNDI lookup in which the container calls the zero argument version of the anottated method.
Any ideias on how to do it in EJB 3.0?
tks
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083444#4083444
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083444
18 years, 8 months
[EJB/JBoss] - detached entity passed to persist
by kaviarasu
hi im using two tables where Table1 refers Table2 by manytoOne annotation
here im using the following code to insert in primary and secondry table
when the register() is called it insert in the database
when the String edit() method is called it edit the particular review and update the review
then for second time register() is called detached entity passed to persist entity.beans.TblReviews error comes ......
how to over come this
even i used em.flush();
| em.refresh(tr);
still the error comes how to reoslve this
@Stateful
|
| @Name("search")
| public class SearchAction
| implements Search,
| Serializable
| {
| static final long serialVersionUID = -6536629890251170098L;
|
| @PersistenceContext
| EntityManager em;
|
| @RequestParameter
| BigDecimal id;
|
| @RequestParameter
| BigDecimal revid;
|
|
| @Out(required=false)
| TblProducts pro;
|
| @DataModel
| private List rev;
|
| @Out(required=false)
| Long rid4comm1;
|
| @In (required=false)
| Identity identity;
|
| TblReviews tr=new TblReviews();
| @In(required=false)
| @Out(required=false)
| TblUserReviews tblu;
|
| @Out(required=false)
| List<TblUserReviews> editreview;
|
| @Begin(join=true)
| public void selectFromRequest() {
|
| if (id != null) {
| pro = em.find(TblProducts.class, id);
| details = em.createQuery("select s from SearchBean s where s.storeProductId in (select st2.storeProductId from TblProductStore st2 where st2.productId="+id+")").getResultList();
| rev= em.createQuery("select p from TblReviews p where productId="+id+"").getResultList();
|
| }
| }
| @Begin(join=true)
| public String register() {
| tr.setProductId(pro);
| tr.setUserId(identity.getUsername());
| Set<TblUserReviews> tblUserReviewsCollection= new TreeSet<TblUserReviews>();
| tblu.setReviewEntryId(tr);
| tblUserReviewsCollection.add(tblu);
| tr.setTblUserReviewsCollection(tblUserReviewsCollection);
| em.persist(tr);
| em.flush();
| em.refresh(tr);
| return "/prodis.xhtml";
| }
| @Begin(join=true)
| public String edit() {
| em.merge(tblu);
| return "/prodis.xhtml";
| }
|
| @Begin(join=true)
| public void editReview(){
| editreview= (List<TblUserReviews>) em.createQuery("select p from TblUserReviews p where userReviewId="+revid+"").getResultList();
| tblu = (TblUserReviews) editreview.get(0);
| }
| @End
| public void reset() {}
|
| @Destroy
| @Remove
| public void destroy() {}
|
| }
thank u regards
kavi
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4083443#4083443
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4083443
18 years, 8 months