You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by "E. Lefty Kreouzis" <le...@internet.gr> on 2004/11/15 22:23:22 UTC

Error reporting

Hi,

I am trying to develop a simple web application.
This application fills in a form and tries to insert it into a table.
Sometimes the insert doesn't work because of an integrity constraint
error (duplicate value, foreign key error etc).
My question is this: in the insert method how can I report the error in
such a way that <h:message > and/or <h:messages> will pick it up and
report it as if it were a validation error?

FacesMessage instances are created in the Validator and/or Converter
classes and then thrown as exceptions. The JSF framework then catches
the exception unravels the message and somehow associates it with the
correct UIInput component so that the <h:message> and <h:messages> tags
can retrieve them and display them.

But I can't find how to associate a FacesMessage with a particular
component.

Any and all help will be much appreciated,

Thank you in advance

Lefty Kreouzis


-- 
E. Lefty Kreouzis <le...@internet.gr>


Antwort: Re: Antwort: Re: ValueChangeEvent and ValueChangeListener

Posted by ch...@globus.ch.
Thanks alot! I've found my sku model now...

Next problem is, that my model gets overridden each time by the values 
from the screen, which I have changed in my ValueChangeListener.
I think I have to deal with the Phases as next ;-)

Cheers

 Chris





Heath Borders-Wing <he...@gmail.com>
16.11.2004 16:37
Bitte antworten an "MyFaces Discussion"
 
        An:     MyFaces Discussion <my...@incubator.apache.org>
        Kopie: 
        Thema:  Re: Antwort: Re: ValueChangeEvent and ValueChangeListener


My fault.  That's a custom method in a helper class I wrote.  I've
just gotten so used to it! :-)

Here is the code that will get you a request bean:

FacesContext ctx = FacesContext.getCurrentInstance();
ctx.getExternalContext().getRequestMap().get(p_name);


On Tue, 16 Nov 2004 16:34:39 +0100, christian.rueedi@globus.ch
<ch...@globus.ch> wrote:
>
> Maybe I'm stupid, but I haven't found any getRequestBean Method on
> FacesContext neither in other classes.
>
> I tried myfaces 1.0.7 aswell...
>
> Can you give me a hint?
>
> Chris
>
>
>
>
> Heath Borders-Wing <he...@gmail.com>
>
> 16.11.2004 15:02
> Bitte antworten an "MyFaces Discussion"
>         An:        MyFaces Discussion 
<my...@incubator.apache.org>
>         Kopie:
>         Thema:        Re: ValueChangeEvent and ValueChangeListener
>
>
>
>
> Yes, you call FacesContext.getRequestBean(String) and pass in the name
> of the var you gave to the dataTable.  All UIData elements place that
> variable in request scope when a component from a row broadcasts and
> event.
>
>
> On Tue, 16 Nov 2004 10:58:13 +0100, christian.rueedi@globus.ch
> <ch...@globus.ch> wrote:
> >
> > Hi there,
> >
> > short: Can I get the model object of a row in a dataTable out of the 
event
> > object in the ValueChangeListener method?
> >
> > long:
> > I try to do something with the ValueChangeEvent. My itension is like 
this:
> > I have an order screen, where the user types in different values of an
> > order.
> > The main part is a dataTable with SKU Lines(item lines). Now the user
> wants
> > to type in the sku number and the application should fetch all the
> > data(description,
> > price,vat) from the database by it self.
> > So I added a ValueChangeListener to my InputText Field. I get into the
> > method but
> > I don't know how to get the model object of my sku line. I tried with 
the
> > ValueBindingMap
> > but had no luck to find the right path....
> >
> > A workaround would be to make the ValueChangeListener on the skuline 
model
> > object.
> > Then I could reference the model easily with "this". But I don't like 
to
> > have to JSF GUI Method
> > on my generic skuline model object....
> >
> > Here are my classes:
> >
> > public class WVSForm <--------------  This is my BackingBean
> > {
> >         private              WVS        a_WVSObject                 =
> null;
> >
> >         public void 
skuChangeListener(javax.faces.event.ValueChangeEvent
> > event)
> >         {
> >
> >                         Integer t_skunbr = 
(Integer)event.getNewValue();
> >
> >                 ValueBinding t_bind =
> > event.getComponent().getValueBinding("value");
> >                 String t_wvsSkuLineItemEL = 
t_bind.getExpressionString();
> >                 Object t_source = event.getSource();
> >                 Object t_skulineItem =
> >
> 
FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(),t_wvsSkuLineItemEL);
> >
> >
> >                 System.out.println("");
> >
> >
> 
//GkSkuBroker.current().getFullSku(t_skunbr.toString(),"1",event.getSource())
> >         }
> > }
> >
> > public class WVS  <----------------------- This is my order model
> > {
> >         private java.lang.Integer a_Rayon;
> >         private java.lang.Integer a_Company;
> >         private java.lang.String a_UserId;
> >         private java.lang.Integer a_Status;
> >         private java.util.Date a_CreateDate;
> >         private BigDecimal a_TotalCostAmount = new BigDecimal(0.00d);
> >         private java.util.List a_SkuLineItemList; //
> > <-------------------------------------   this is my List of skulines
> >         private Integer a_WvsNbr;
> >         private Integer a_SenderBranch;
> >         private Integer a_ReceiverBranch;
> > }
> >
> > public class WVSSkuLineItem  <------------------------ This is my 
skuline
> > model
> > {
> >
> >         private java.lang.String a_Descriptionvendor;
> >         private java.lang.Integer a_Skunbr;
> >         private String a_SkuType = "1";  // TODO fix this with the
> skubroker
> >         private BigDecimal a_Costamount = new BigDecimal(new
> > BigInteger("0"),2);
> >         private Integer a_Seqnbr;
> >         private BigDecimal a_Quantity = new BigDecimal(new
> > BigInteger("0"),3);
> >         private BigDecimal a_Costprice = new BigDecimal(new
> > BigInteger("0"),2);
> >         private BigDecimal a_Retailprice = new BigDecimal(new
> > BigInteger("0"),2);
> >         private java.lang.String a_Description;
> >         private BigDecimal a_Retailamount = new BigDecimal(new
> > BigInteger("0"),2);
> >         private WVS a_Header;
> >         private Integer a_Company;
> > }
> >
> > And the JSP entry:
> >
> > <x:dataTable
> >         id="skuListTable"
> >         styleClass="InsideFieldSetSkuTable"
> >         style="border-collapse  : collapse;"
> >         headerClass="BoldText"
> >         rowClasses="FormNormal"
> >         columnClasses="TableInputButton NormalText, FillerSmall,
> > FieldFormMedium NormalText TextLeftAlign,Filler,FieldForm NormalText
> >                                                         var="sku"
> >         value="#{WVSForm.a_WVSObject.a_SkuLineItemList}"
> >          >
> >
> >           <h:column >
> >                 <f:facet name="header">
> >                   <h:outputText value="#{msg.WVS_sku_nbr}" />
> >                 </f:facet>
> >                 <x:message for="skunbr" detailFormat="*"
> > styleClass="ErrorText" />
> >                 <h:inputText id="skunbr" value="#{sku.a_Skunbr}"
> > required="true" styleClass="FieldFormMedium NormalText TextLeftAlign"
> > valueChangeListener="#{WVSForm.skuChangeListener}"  >
> >                   <f:validateLength minimum="8" maximum="8" />
> >                 </h:inputText>
> >           </h:column>
> > </x:dataTable>
> >
> >
> > Thanks for reading this!
> >
> > Chris
> >
>
>
> --
> If you don't have a GMail account, I probably have 5 invites.  Just ask!
> -Heath Borders-Wing
> hborders@mail.win.org
>


--
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

Re: Antwort: Re: ValueChangeEvent and ValueChangeListener

Posted by Heath Borders-Wing <he...@gmail.com>.
My fault.  That's a custom method in a helper class I wrote.  I've
just gotten so used to it! :-)

Here is the code that will get you a request bean:

FacesContext ctx = FacesContext.getCurrentInstance();
ctx.getExternalContext().getRequestMap().get(p_name);


On Tue, 16 Nov 2004 16:34:39 +0100, christian.rueedi@globus.ch
<ch...@globus.ch> wrote:
> 
> Maybe I'm stupid, but I haven't found any getRequestBean Method on
> FacesContext neither in other classes. 
> 
> I tried myfaces 1.0.7 aswell... 
> 
> Can you give me a hint? 
> 
> Chris 
> 
> 
> 
> 
> Heath Borders-Wing <he...@gmail.com> 
> 
> 16.11.2004 15:02 
> Bitte antworten an "MyFaces Discussion"         
>         An:        MyFaces Discussion <my...@incubator.apache.org> 
>         Kopie:         
>         Thema:        Re: ValueChangeEvent and ValueChangeListener
> 
> 
> 
> 
> Yes, you call FacesContext.getRequestBean(String) and pass in the name
> of the var you gave to the dataTable.  All UIData elements place that
> variable in request scope when a component from a row broadcasts and
> event.
> 
> 
> On Tue, 16 Nov 2004 10:58:13 +0100, christian.rueedi@globus.ch
> <ch...@globus.ch> wrote:
> >
> > Hi there,
> >
> > short: Can I get the model object of a row in a dataTable out of the event
> > object in the ValueChangeListener method?
> >
> > long:
> > I try to do something with the ValueChangeEvent. My itension is like this:
> > I have an order screen, where the user types in different values of an
> > order.
> > The main part is a dataTable with SKU Lines(item lines). Now the user
> wants
> > to type in the sku number and the application should fetch all the
> > data(description,
> > price,vat) from the database by it self.
> > So I added a ValueChangeListener to my InputText Field. I get into the
> > method but
> > I don't know how to get the model object of my sku line. I tried with the
> > ValueBindingMap
> > but had no luck to find the right path....
> >
> > A workaround would be to make the ValueChangeListener on the skuline model
> > object.
> > Then I could reference the model easily with "this". But I don't like to
> > have to JSF GUI Method
> > on my generic skuline model object....
> >
> > Here are my classes:
> >
> > public class WVSForm <--------------  This is my BackingBean
> > {
> >         private              WVS        a_WVSObject                 =
> null;
> >
> >         public void skuChangeListener(javax.faces.event.ValueChangeEvent
> > event)
> >         {
> >
> >                         Integer t_skunbr = (Integer)event.getNewValue();
> >
> >                 ValueBinding t_bind =
> > event.getComponent().getValueBinding("value");
> >                 String t_wvsSkuLineItemEL = t_bind.getExpressionString();
> >                 Object t_source = event.getSource();
> >                 Object t_skulineItem =
> >
> FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(),t_wvsSkuLineItemEL);
> >
> >
> >                 System.out.println("");
> >
> >
> //GkSkuBroker.current().getFullSku(t_skunbr.toString(),"1",event.getSource())
> >         }
> > }
> >
> > public class WVS  <----------------------- This is my order model
> > {
> >         private java.lang.Integer a_Rayon;
> >         private java.lang.Integer a_Company;
> >         private java.lang.String a_UserId;
> >         private java.lang.Integer a_Status;
> >         private java.util.Date a_CreateDate;
> >         private BigDecimal a_TotalCostAmount = new BigDecimal(0.00d);
> >         private java.util.List a_SkuLineItemList; //
> > <-------------------------------------   this is my List of skulines
> >         private Integer a_WvsNbr;
> >         private Integer a_SenderBranch;
> >         private Integer a_ReceiverBranch;
> > }
> >
> > public class WVSSkuLineItem  <------------------------ This is my skuline
> > model
> > {
> >
> >         private java.lang.String a_Descriptionvendor;
> >         private java.lang.Integer a_Skunbr;
> >         private String a_SkuType = "1";  // TODO fix this with the
> skubroker
> >         private BigDecimal a_Costamount = new BigDecimal(new
> > BigInteger("0"),2);
> >         private Integer a_Seqnbr;
> >         private BigDecimal a_Quantity = new BigDecimal(new
> > BigInteger("0"),3);
> >         private BigDecimal a_Costprice = new BigDecimal(new
> > BigInteger("0"),2);
> >         private BigDecimal a_Retailprice = new BigDecimal(new
> > BigInteger("0"),2);
> >         private java.lang.String a_Description;
> >         private BigDecimal a_Retailamount = new BigDecimal(new
> > BigInteger("0"),2);
> >         private WVS a_Header;
> >         private Integer a_Company;
> > }
> >
> > And the JSP entry:
> >
> > <x:dataTable
> >         id="skuListTable"
> >         styleClass="InsideFieldSetSkuTable"
> >         style="border-collapse  : collapse;"
> >         headerClass="BoldText"
> >         rowClasses="FormNormal"
> >         columnClasses="TableInputButton NormalText, FillerSmall,
> > FieldFormMedium NormalText TextLeftAlign,Filler,FieldForm NormalText
> >                                                         var="sku"
> >         value="#{WVSForm.a_WVSObject.a_SkuLineItemList}"
> >          >
> >
> >           <h:column >
> >                 <f:facet name="header">
> >                   <h:outputText value="#{msg.WVS_sku_nbr}" />
> >                 </f:facet>
> >                 <x:message for="skunbr" detailFormat="*"
> > styleClass="ErrorText" />
> >                 <h:inputText id="skunbr" value="#{sku.a_Skunbr}"
> > required="true" styleClass="FieldFormMedium NormalText TextLeftAlign"
> > valueChangeListener="#{WVSForm.skuChangeListener}"  >
> >                   <f:validateLength minimum="8" maximum="8" />
> >                 </h:inputText>
> >           </h:column>
> > </x:dataTable>
> >
> >
> > Thanks for reading this!
> >
> > Chris
> >
> 
> 
> --
> If you don't have a GMail account, I probably have 5 invites.  Just ask!
> -Heath Borders-Wing 
> hborders@mail.win.org 
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

Antwort: Re: ValueChangeEvent and ValueChangeListener

Posted by ch...@globus.ch.
Maybe I'm stupid, but I haven't found any getRequestBean Method on 
FacesContext neither in other classes.

I tried myfaces 1.0.7 aswell...

Can you give me a hint?

Chris





Heath Borders-Wing <he...@gmail.com>
16.11.2004 15:02
Bitte antworten an "MyFaces Discussion"
 
        An:     MyFaces Discussion <my...@incubator.apache.org>
        Kopie: 
        Thema:  Re: ValueChangeEvent and ValueChangeListener


Yes, you call FacesContext.getRequestBean(String) and pass in the name
of the var you gave to the dataTable.  All UIData elements place that
variable in request scope when a component from a row broadcasts and
event.


On Tue, 16 Nov 2004 10:58:13 +0100, christian.rueedi@globus.ch
<ch...@globus.ch> wrote:
>
> Hi there,
>
> short: Can I get the model object of a row in a dataTable out of the 
event
> object in the ValueChangeListener method?
>
> long:
> I try to do something with the ValueChangeEvent. My itension is like 
this:
> I have an order screen, where the user types in different values of an
> order.
> The main part is a dataTable with SKU Lines(item lines). Now the user 
wants
> to type in the sku number and the application should fetch all the
> data(description,
> price,vat) from the database by it self.
> So I added a ValueChangeListener to my InputText Field. I get into the
> method but
> I don't know how to get the model object of my sku line. I tried with 
the
> ValueBindingMap
> but had no luck to find the right path....
>
> A workaround would be to make the ValueChangeListener on the skuline 
model
> object.
> Then I could reference the model easily with "this". But I don't like to
> have to JSF GUI Method
> on my generic skuline model object....
>
> Here are my classes:
>
> public class WVSForm <--------------  This is my BackingBean
> {
>         private              WVS        a_WVSObject                 = 
null;
>
>         public void skuChangeListener(javax.faces.event.ValueChangeEvent
> event)
>         {
>
>                         Integer t_skunbr = (Integer)event.getNewValue();
>
>                 ValueBinding t_bind =
> event.getComponent().getValueBinding("value");
>                 String t_wvsSkuLineItemEL = 
t_bind.getExpressionString();
>                 Object t_source = event.getSource();
>                 Object t_skulineItem =
> 
FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(),t_wvsSkuLineItemEL);
>
>
>                 System.out.println("");
>
> 
//GkSkuBroker.current().getFullSku(t_skunbr.toString(),"1",event.getSource())
>         }
> }
>
> public class WVS  <----------------------- This is my order model
> {
>         private java.lang.Integer a_Rayon;
>         private java.lang.Integer a_Company;
>         private java.lang.String a_UserId;
>         private java.lang.Integer a_Status;
>         private java.util.Date a_CreateDate;
>         private BigDecimal a_TotalCostAmount = new BigDecimal(0.00d);
>         private java.util.List a_SkuLineItemList; //
> <-------------------------------------   this is my List of skulines
>         private Integer a_WvsNbr;
>         private Integer a_SenderBranch;
>         private Integer a_ReceiverBranch;
> }
>
> public class WVSSkuLineItem  <------------------------ This is my 
skuline
> model
> {
>
>         private java.lang.String a_Descriptionvendor;
>         private java.lang.Integer a_Skunbr;
>         private String a_SkuType = "1";  // TODO fix this with the 
skubroker
>         private BigDecimal a_Costamount = new BigDecimal(new
> BigInteger("0"),2);
>         private Integer a_Seqnbr;
>         private BigDecimal a_Quantity = new BigDecimal(new
> BigInteger("0"),3);
>         private BigDecimal a_Costprice = new BigDecimal(new
> BigInteger("0"),2);
>         private BigDecimal a_Retailprice = new BigDecimal(new
> BigInteger("0"),2);
>         private java.lang.String a_Description;
>         private BigDecimal a_Retailamount = new BigDecimal(new
> BigInteger("0"),2);
>         private WVS a_Header;
>         private Integer a_Company;
> }
>
> And the JSP entry:
>
> <x:dataTable
>         id="skuListTable"
>         styleClass="InsideFieldSetSkuTable"
>         style="border-collapse  : collapse;"
>         headerClass="BoldText"
>         rowClasses="FormNormal"
>         columnClasses="TableInputButton NormalText, FillerSmall,
> FieldFormMedium NormalText TextLeftAlign,Filler,FieldForm NormalText
>                                                         var="sku"
>         value="#{WVSForm.a_WVSObject.a_SkuLineItemList}"
>          >
>
>           <h:column >
>                 <f:facet name="header">
>                   <h:outputText value="#{msg.WVS_sku_nbr}" />
>                 </f:facet>
>                 <x:message for="skunbr" detailFormat="*"
> styleClass="ErrorText" />
>                 <h:inputText id="skunbr" value="#{sku.a_Skunbr}"
> required="true" styleClass="FieldFormMedium NormalText TextLeftAlign"
> valueChangeListener="#{WVSForm.skuChangeListener}"  >
>                   <f:validateLength minimum="8" maximum="8" />
>                 </h:inputText>
>           </h:column>
> </x:dataTable>
>
>
> Thanks for reading this!
>
> Chris
>


--
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

Re: ValueChangeEvent and ValueChangeListener

Posted by Heath Borders-Wing <he...@gmail.com>.
Yes, you call FacesContext.getRequestBean(String) and pass in the name
of the var you gave to the dataTable.  All UIData elements place that
variable in request scope when a component from a row broadcasts and
event.


On Tue, 16 Nov 2004 10:58:13 +0100, christian.rueedi@globus.ch
<ch...@globus.ch> wrote:
> 
> Hi there, 
> 
> short: Can I get the model object of a row in a dataTable out of the event
> object in the ValueChangeListener method? 
> 
> long: 
> I try to do something with the ValueChangeEvent. My itension is like this: 
> I have an order screen, where the user types in different values of an
> order. 
> The main part is a dataTable with SKU Lines(item lines). Now the user wants 
> to type in the sku number and the application should fetch all the
> data(description, 
> price,vat) from the database by it self. 
> So I added a ValueChangeListener to my InputText Field. I get into the
> method but 
> I don't know how to get the model object of my sku line. I tried with the
> ValueBindingMap 
> but had no luck to find the right path.... 
> 
> A workaround would be to make the ValueChangeListener on the skuline model
> object. 
> Then I could reference the model easily with "this". But I don't like to
> have to JSF GUI Method 
> on my generic skuline model object.... 
> 
> Here are my classes: 
> 
> public class WVSForm <--------------  This is my BackingBean 
> { 
>         private              WVS        a_WVSObject                 = null; 
>         
>         public void skuChangeListener(javax.faces.event.ValueChangeEvent
> event) 
>         { 
> 
>                         Integer t_skunbr = (Integer)event.getNewValue(); 
> 
>                 ValueBinding t_bind =
> event.getComponent().getValueBinding("value"); 
>                 String t_wvsSkuLineItemEL = t_bind.getExpressionString(); 
>                 Object t_source = event.getSource(); 
>                 Object t_skulineItem =
> FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(),t_wvsSkuLineItemEL);
> 
> 
>                 System.out.println(""); 
>                
> //GkSkuBroker.current().getFullSku(t_skunbr.toString(),"1",event.getSource())
>         } 
> } 
> 
> public class WVS  <----------------------- This is my order model 
> { 
>         private java.lang.Integer a_Rayon; 
>         private java.lang.Integer a_Company; 
>         private java.lang.String a_UserId; 
>         private java.lang.Integer a_Status; 
>         private java.util.Date a_CreateDate; 
>         private BigDecimal a_TotalCostAmount = new BigDecimal(0.00d); 
>         private java.util.List a_SkuLineItemList; //
> <-------------------------------------   this is my List of skulines 
>         private Integer a_WvsNbr; 
>         private Integer a_SenderBranch; 
>         private Integer a_ReceiverBranch; 
> } 
> 
> public class WVSSkuLineItem  <------------------------ This is my skuline
> model 
> { 
> 
>         private java.lang.String a_Descriptionvendor; 
>         private java.lang.Integer a_Skunbr; 
>         private String a_SkuType = "1";  // TODO fix this with the skubroker
>         private BigDecimal a_Costamount = new BigDecimal(new
> BigInteger("0"),2); 
>         private Integer a_Seqnbr; 
>         private BigDecimal a_Quantity = new BigDecimal(new
> BigInteger("0"),3); 
>         private BigDecimal a_Costprice = new BigDecimal(new
> BigInteger("0"),2); 
>         private BigDecimal a_Retailprice = new BigDecimal(new
> BigInteger("0"),2); 
>         private java.lang.String a_Description; 
>         private BigDecimal a_Retailamount = new BigDecimal(new
> BigInteger("0"),2); 
>         private WVS a_Header; 
>         private Integer a_Company; 
> } 
> 
> And the JSP entry: 
> 
> <x:dataTable 
>         id="skuListTable" 
>         styleClass="InsideFieldSetSkuTable" 
>         style="border-collapse  : collapse;" 
>         headerClass="BoldText" 
>         rowClasses="FormNormal" 
>         columnClasses="TableInputButton NormalText, FillerSmall,
> FieldFormMedium NormalText TextLeftAlign,Filler,FieldForm NormalText        
>                                                         var="sku" 
>         value="#{WVSForm.a_WVSObject.a_SkuLineItemList}" 
>          > 
>         
>           <h:column > 
>                 <f:facet name="header"> 
>                   <h:outputText value="#{msg.WVS_sku_nbr}" /> 
>                 </f:facet> 
>                 <x:message for="skunbr" detailFormat="*"
> styleClass="ErrorText" /> 
>                 <h:inputText id="skunbr" value="#{sku.a_Skunbr}"
> required="true" styleClass="FieldFormMedium NormalText TextLeftAlign"
> valueChangeListener="#{WVSForm.skuChangeListener}"  > 
>                   <f:validateLength minimum="8" maximum="8" /> 
>                 </h:inputText> 
>           </h:column> 
> </x:dataTable> 
> 
> 
> Thanks for reading this! 
> 
> Chris 
> 


-- 
If you don't have a GMail account, I probably have 5 invites.  Just ask!
-Heath Borders-Wing
hborders@mail.win.org

ValueChangeEvent and ValueChangeListener

Posted by ch...@globus.ch.
Hi there,

short: Can I get the model object of a row in a dataTable out of the event 
object in the ValueChangeListener method?

long:
I try to do something with the ValueChangeEvent. My itension is like this:
I have an order screen, where the user types in different values of an 
order. 
The main part is a dataTable with SKU Lines(item lines). Now the user 
wants
to type in the sku number and the application should fetch all the 
data(description,
price,vat) from the database by it self.
So I added a ValueChangeListener to my InputText Field. I get into the 
method but
I don't know how to get the model object of my sku line. I tried with the 
ValueBindingMap
but had no luck to find the right path....

A workaround would be to make the ValueChangeListener on the skuline model 
object.
Then I could reference the model easily with "this". But I don't like to 
have to JSF GUI Method
on my generic skuline model object....

Here are my classes:

public class WVSForm <--------------  This is my BackingBean
{
        private              WVS        a_WVSObject                 = 
null;
 
        public void skuChangeListener(javax.faces.event.ValueChangeEvent 
event)
        {

                        Integer t_skunbr = (Integer)event.getNewValue();

                ValueBinding t_bind = 
event.getComponent().getValueBinding("value");
                String t_wvsSkuLineItemEL = t_bind.getExpressionString();
                Object t_source = event.getSource();
                Object t_skulineItem = 
FacesContext.getCurrentInstance().getApplication().getVariableResolver().resolveVariable(FacesContext.getCurrentInstance(),t_wvsSkuLineItemEL);


                System.out.println("");
 
//GkSkuBroker.current().getFullSku(t_skunbr.toString(),"1",event.getSource())
        }
}

public class WVS  <----------------------- This is my order model
{
        private java.lang.Integer a_Rayon;
        private java.lang.Integer a_Company;
        private java.lang.String a_UserId;
        private java.lang.Integer a_Status;
        private java.util.Date a_CreateDate;
        private BigDecimal a_TotalCostAmount = new BigDecimal(0.00d);
        private java.util.List a_SkuLineItemList; // 
<-------------------------------------   this is my List of skulines
        private Integer a_WvsNbr;
        private Integer a_SenderBranch;
        private Integer a_ReceiverBranch;
}

public class WVSSkuLineItem  <------------------------ This is my skuline 
model
{

        private java.lang.String a_Descriptionvendor;
        private java.lang.Integer a_Skunbr;
        private String a_SkuType = "1";  // TODO fix this with the 
skubroker
        private BigDecimal a_Costamount = new BigDecimal(new 
BigInteger("0"),2);
        private Integer a_Seqnbr;
        private BigDecimal a_Quantity = new BigDecimal(new 
BigInteger("0"),3);
        private BigDecimal a_Costprice = new BigDecimal(new 
BigInteger("0"),2);
        private BigDecimal a_Retailprice = new BigDecimal(new 
BigInteger("0"),2);
        private java.lang.String a_Description;
        private BigDecimal a_Retailamount = new BigDecimal(new 
BigInteger("0"),2);
        private WVS a_Header;
        private Integer a_Company;
}

And the JSP entry:

<x:dataTable
        id="skuListTable"
        styleClass="InsideFieldSetSkuTable"
        style="border-collapse  : collapse;"
        headerClass="BoldText"
        rowClasses="FormNormal"
        columnClasses="TableInputButton NormalText, FillerSmall, 
FieldFormMedium NormalText TextLeftAlign,Filler,FieldForm NormalText    
var="sku"
        value="#{WVSForm.a_WVSObject.a_SkuLineItemList}"
         >
 
          <h:column >
                <f:facet name="header">
                  <h:outputText value="#{msg.WVS_sku_nbr}" />
                </f:facet>
                <x:message for="skunbr" detailFormat="*" 
styleClass="ErrorText" />
                <h:inputText id="skunbr" value="#{sku.a_Skunbr}" 
required="true" styleClass="FieldFormMedium NormalText TextLeftAlign" 
valueChangeListener="#{WVSForm.skuChangeListener}"  >
                  <f:validateLength minimum="8" maximum="8" />
                </h:inputText>
          </h:column>
</x:dataTable>


Thanks for reading this!

Chris

Re: Error reporting

Posted by Manfred Geiler <ma...@apache.org>.
Simply create a new FacesMessage and add it with the following 
FacesContext method:
     public abstract void addMessage(String clientId, 
                   javax.faces.application.FacesMessage message);

Hint: Don't forget to pass the whole clientId (full semicolon separated 
"path") of your component, not only the componentId.

HTH,
Manfred



E. Lefty Kreouzis wrote:
> Hi,
> 
> I am trying to develop a simple web application.
> This application fills in a form and tries to insert it into a table.
> Sometimes the insert doesn't work because of an integrity constraint
> error (duplicate value, foreign key error etc).
> My question is this: in the insert method how can I report the error in
> such a way that <h:message > and/or <h:messages> will pick it up and
> report it as if it were a validation error?
> 
> FacesMessage instances are created in the Validator and/or Converter
> classes and then thrown as exceptions. The JSF framework then catches
> the exception unravels the message and somehow associates it with the
> correct UIInput component so that the <h:message> and <h:messages> tags
> can retrieve them and display them.
> 
> But I can't find how to associate a FacesMessage with a particular
> component.
> 
> Any and all help will be much appreciated,
> 
> Thank you in advance
> 
> Lefty Kreouzis
> 
>