If you programmically create a message, you either need to assign the
"table" client-id to the message (instead of null) or you need to
display global messages and not just "table" messages.

On 7/8/08, Henry Chang <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Hi,
>
>
>
> Thank you for your suggestion. Then how could I display the error message on
> the screen? I tried to use <tr:message> but it does not display anything.
>
>
>
> <tr:commandButton id="table" text="Next" action="#{BackingBean.next}" />
>
>  <tr:message for="table" />
>
>
>
>
>
> Henry
>
>
>
>
>
> From: Guy Bashan [mailto:[EMAIL PROTECTED]
>  Sent: Tuesday, July 08, 2008 3:49 PM
>  To: 'MyFaces Discussion'
>  Subject: RE: How to validate a <tr:table>
>
>
>
>
> Hi,
>
>
>
> Why not just writing the validation code in the action of the command
> button?
>
>
>
> <h:commandButton value="next" action="myBean.next" />
>
>
>
> And in the bean:
>
>
>
> ..
>
> ..
>
> public String next()
>
> {
>
>   If (rowSelected != null)
>
>   {
>
>     return "next";
>
>   }
>
> else
>
> {
>
>
> FacesContext.getCurrentInstance().addMessage(
>
>         null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
> "Select row", "Select row"));
>
>   return null;
>
> }
>
>
>
>
>
> Guy.
>
>
>
>
>
> From: Henry Chang [mailto:[EMAIL PROTECTED]
>  Sent: Tuesday, July 08, 2008 6:31 AM
>  To: MyFaces Discussion
>  Subject: How to validate a <tr:table>
>
>
>
>
> Hi, I've got a simple question regarding to validating <tr:table> component.
> I just want to make sure that at least one of the rows in the table are
> being selected before proceeding to the next page, after pressing the submit
> button. I have validation code like this:
>
>
>
>
>
> private CoreTable product;
>
>
>
>
>
> public void validateToCart(FacesContext context, UIComponent toValidate,
>              Object value) throws ValidatorException {
>          Iterator selection =
> product.getSelectedRowKeys().iterator();
>          if (!selection.hasNext()) {
>              FacesMessage message = new FacesMessage("No items selected!");
>              throw new ValidatorException(message);
>          }
>      }
>
>
>
>
>
>
>
>
> How do I call this method from the page? I found that there is no validator
> attribute in the <tr:table> component nor in the <tr:commandButton>
> component. Thanks.
>
>
>
>
>
> Best Regards,
>
>
> Henry Chang

Reply via email to