List Info

Thread: t:dataTable: how to change css-style on single cells after conversion error?




t:dataTable: how to change css-style on single cells after conversion error?
country flaguser name
United States
2007-08-30 11:10:37
I have a t:dataTable where users can input numbers (a
worksheet like in
excel).
I wrote a custom converter in order to convert the Strings
to a Number. If
the format is not the one I expect I would like to change
the css-styleClass
of the cell(s) with wrong input so the user can see quickly
in which cell
the error happened (and additionally I print an
error-message on top of the
screen).

      <t:dataTable var="row"
value="#{Bean.list}" >
	<t:column>
		<t:inputText value="#{row.value}"
converter="myConverter"
	                 styleClass="#{StyleBean.style]}"
/>
	</t:column>
              ...
       </t:dataTable>

My converter works, but I don't know how to change the style
of the
input-component. The following code does not work, it
changes me the error
class of the whole column!

	public Double getAsObject(FacesContext fc, UIComponent uc,
String asString)
			throws ConverterException {
		
		Double doubleValue = null;
		try {
                                  ..... //convert the string
to a double
		} catch (Exception e) {
                                     
((HtmlInputText)uc).setStyleClass("errorStyle");
                                       FacesMessage
facesMessage = ....
			throw new ConverterException(facesMessage);
		}
		return doubleValue;
	}

Does anyone know how I can solve this problem?
Any help is appreciated.

Many Thanks
Peter
-- 
View this message in context: http://www.nabble.com/t%3AdataTable%3A-how-to
-change-css-style-on-single-cells-after-conversion-error--tf
4355282.html#a12410633
Sent from the MyFaces - Users mailing list archive at
Nabble.com.


Re: t:dataTable: how to change css-style on single cells after conversion error?
user name
2007-08-30 11:19:37
If you want to use Seam they have the ability to wrap
components with messages:

http://docs.jboss.org/seam/1.2.1.GA/refe
rence/en/html_single/#validation

On 8/30/07, Peter Steiner <matthias.agethlesiag.it> wrote:
>
> I have a t:dataTable where users can input numbers (a
worksheet like in
> excel).
> I wrote a custom converter in order to convert the
Strings to a Number. If
> the format is not the one I expect I would like to
change the css-styleClass
> of the cell(s) with wrong input so the user can see
quickly in which cell
> the error happened (and additionally I print an
error-message on top of the
> screen).
>
>       <t:dataTable var="row"
value="#{Bean.list}" >
>         <t:column>
>                 <t:inputText
value="#{row.value}"
converter="myConverter"
>                         
styleClass="#{StyleBean.style]}" />
>         </t:column>
>               ...
>        </t:dataTable>
>
> My converter works, but I don't know how to change the
style of the
> input-component. The following code does not work, it
changes me the error
> class of the whole column!
>
>         public Double getAsObject(FacesContext fc,
UIComponent uc, String asString)
>                         throws ConverterException {
>
>                 Double doubleValue = null;
>                 try {
>                                   ..... //convert the
string to a double
>                 } catch (Exception e) {
>
>
((HtmlInputText)uc).setStyleClass("errorStyle");
>                                        FacesMessage
facesMessage = ....
>                         throw new
ConverterException(facesMessage);
>                 }
>                 return doubleValue;
>         }
>
> Does anyone know how I can solve this problem?
> Any help is appreciated.
>
> Many Thanks
> Peter
> --
> View this message in context: http://www.nabble.com/t%3AdataTable%3A-how-to
-change-css-style-on-single-cells-after-conversion-error--tf
4355282.html#a12410633
> Sent from the MyFaces - Users mailing list archive at
Nabble.com.
>
>

Re: t:dataTable: how to change css-style on single cells after conversion error?
country flaguser name
United States
2007-08-31 01:23:20
I can't change to Seam anymore.
Didn't anyone face the same problem with MyFaces? 



Andrew Robinson-5 wrote:
> 
> If you want to use Seam they have the ability to wrap
components with
> messages:
> 
> http://docs.jboss.org/seam/1.2.1.GA/refe
rence/en/html_single/#validation
> 
> On 8/30/07, Peter Steiner <matthias.agethlesiag.it> wrote:
>>
>> I have a t:dataTable where users can input numbers
(a worksheet like in
>> excel).
>> I wrote a custom converter in order to convert the
Strings to a Number.
>> If
>> the format is not the one I expect I would like to
change the
>> css-styleClass
>> of the cell(s) with wrong input so the user can see
quickly in which cell
>> the error happened (and additionally I print an
error-message on top of
>> the
>> screen).
>>
>>       <t:dataTable var="row"
value="#{Bean.list}" >
>>         <t:column>
>>                 <t:inputText
value="#{row.value}"
converter="myConverter"
>>                         
styleClass="#{StyleBean.style]}" />
>>         </t:column>
>>               ...
>>        </t:dataTable>
>>
>> My converter works, but I don't know how to change
the style of the
>> input-component. The following code does not work,
it changes me the
>> error
>> class of the whole column!
>>
>>         public Double getAsObject(FacesContext fc,
UIComponent uc, String
>> asString)
>>                         throws ConverterException
{
>>
>>                 Double doubleValue = null;
>>                 try {
>>                                   ..... //convert
the string to a double
>>                 } catch (Exception e) {
>>
>>
((HtmlInputText)uc).setStyleClass("errorStyle");
>>                                        FacesMessage
facesMessage = ....
>>                         throw new
ConverterException(facesMessage);
>>                 }
>>                 return doubleValue;
>>         }
>>
>> Does anyone know how I can solve this problem?
>> Any help is appreciated.
>>
>> Many Thanks
>> Peter
>> --
>> View this message in context:
>> http://www.nabble.com/t%3AdataTable%3A-how-to
-change-css-style-on-single-cells-after-conversion-error--tf
4355282.html#a12410633
>> Sent from the MyFaces - Users mailing list archive
at Nabble.com.
>>
>>
> 
> 

-- 
View this message in context: http://www.nabble.com/t%3AdataTable%3A-how-to
-change-css-style-on-single-cells-after-conversion-error--tf
4355282.html#a12421299
Sent from the MyFaces - Users mailing list archive at
Nabble.com.


Re: t:dataTable: how to change css-style on single cells after conversion error?
user name
2007-08-31 09:44:54
Just write a wrapper component yourself that you would put
as the
parent in the component tree, it should be easy to do.

Option 1, use invalid:
encodeBegin(...) {
  UIInput child = getChildren().get(0);
  if (!child.isValid())
  {
    // do error encoding here
  }
  else
  {
    // non-error encoding here
  }
}

Option 2: use message:
encodeBegin(...) {
  UIInput child = getChildren().get(0);
  Iterator iter =
facesContext.getMessages(child.getClientId(facesContext));
  // option 1: just switch on existence
  if (iter.hasNext()) {
    // has message code here
  }
  FacesMessage.Severity sev = null;
  // option 2: switch off of severity
  FacesMessage msg;
  while ((msg = (FacesMessage)iter.next()) != null) {
    if (sev == null || msg.getSeverity().getOrdinal() >
sev.getOrdinal()) {
      sev = msg.getSeverity();
    }
  }
  if (sev != null && sev.getOrdinal() >=
FacesMessage.SEVERITY_ERROR.getOrdinal()) {
    // has error code here.
  }
}

On 8/31/07, Peter Steiner <matthias.agethlesiag.it> wrote:
>
> I can't change to Seam anymore.
> Didn't anyone face the same problem with MyFaces?
>
>
>
> Andrew Robinson-5 wrote:
> >
> > If you want to use Seam they have the ability to
wrap components with
> > messages:
> >
> > http://docs.jboss.org/seam/1.2.1.GA/refe
rence/en/html_single/#validation
> >
> > On 8/30/07, Peter Steiner <matthias.agethlesiag.it> wrote:
> >>
> >> I have a t:dataTable where users can input
numbers (a worksheet like in
> >> excel).
> >> I wrote a custom converter in order to convert
the Strings to a Number.
> >> If
> >> the format is not the one I expect I would
like to change the
> >> css-styleClass
> >> of the cell(s) with wrong input so the user
can see quickly in which cell
> >> the error happened (and additionally I print
an error-message on top of
> >> the
> >> screen).
> >>
> >>       <t:dataTable var="row"
value="#{Bean.list}" >
> >>         <t:column>
> >>                 <t:inputText
value="#{row.value}"
converter="myConverter"
> >>                         
styleClass="#{StyleBean.style]}" />
> >>         </t:column>
> >>               ...
> >>        </t:dataTable>
> >>
> >> My converter works, but I don't know how to
change the style of the
> >> input-component. The following code does not
work, it changes me the
> >> error
> >> class of the whole column!
> >>
> >>         public Double getAsObject(FacesContext
fc, UIComponent uc, String
> >> asString)
> >>                         throws
ConverterException {
> >>
> >>                 Double doubleValue = null;
> >>                 try {
> >>                                   .....
//convert the string to a double
> >>                 } catch (Exception e) {
> >>
> >>
((HtmlInputText)uc).setStyleClass("errorStyle");
> >>                                       
FacesMessage facesMessage = ....
> >>                         throw new
ConverterException(facesMessage);
> >>                 }
> >>                 return doubleValue;
> >>         }
> >>
> >> Does anyone know how I can solve this
problem?
> >> Any help is appreciated.
> >>
> >> Many Thanks
> >> Peter
> >> --
> >> View this message in context:
> >> http://www.nabble.com/t%3AdataTable%3A-how-to
-change-css-style-on-single-cells-after-conversion-error--tf
4355282.html#a12410633
> >> Sent from the MyFaces - Users mailing list
archive at Nabble.com.
> >>
> >>
> >
> >
>
> --
> View this message in context: http://www.nabble.com/t%3AdataTable%3A-how-to
-change-css-style-on-single-cells-after-conversion-error--tf
4355282.html#a12421299
> Sent from the MyFaces - Users mailing list archive at
Nabble.com.
>
>

[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )