You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Johan Maasing <jm...@gmail.com> on 2007/08/09 12:57:46 UTC

newbie: best practice for not rendering component?

I am rather new to wicket, coming from a Tapestry angle. Anyway, my
question is rather basic.
I gather that all components on a page must be rendered?
Suppose I have a common dataview with a dataprovider on a page, basic
CRUD-stuff. My page constructor looks like this:

try {
   ...query the database and build the provider and dataview
} catch (SQLException e) {
  feedback.error("Very bad things happened");
  // What to do here??
}

What is the best practice for removing/disabling components in the
catch clause? I can not create the dataview (called "dataview" in the
HTML) since the backend has died but wicket needs a component there?

Currently I do somehting like this

} catch (Exception e) {
  add(new Label("dataview", "").setVisible(false));
}

and that works fine but it seems a bit un-DRY to have to add dummy
components for the error case. Is my understanding correct?

Cheers,
/Johan

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by Johan Maasing <jm...@gmail.com>.
On 8/9/07, Eelco Hillenius <ee...@gmail.com> wrote:
> As for the error-flow, and I don't really see why:
>
> try {
>   ...query the database and build the provider and dataview
> } catch (SQLException e) {
>  feedback.error("Very bad things happened");
>  // What to do here??
> }
>
> should generate a different component structure rather than an error page.
> Eelco

Say that I want to show the page anyway since it might contain other
components that work. My requirements could very well be: A feedback
message saying that part of the page couldn't be rendered, remove the
faulty component (or replace it with a panel containing an error
description) and draw everything else.

So I tried to implement error handling in my data provider. It returns
an empty collection so nothing breaks but I do not get to see any
feedback messages in my feedback panel at the top of the page.
Probably because that component is already rendered when my
dataprovider is invoked.

So, now I'm overriding onAttach to get all my data which works nicely :-)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by James Carman <ja...@carmanconsulting.com>.
Do you know of any websites that currently do what you're talking
about?  When a website has an "internal error" like you're talking
about, most of the time they go to an error page.  However, you can
customize your IExceptionSettings (in your application's init method)
and see if changing the unexpectedExceptionDisplay property does what
you want.

On Thu, Sep 18, 2008 at 12:47 AM, mfs <fa...@gmail.com> wrote:
>
> Well you were right, but you then exceptions are for those exceptional
> scenarios, and we still want to cater those. I would say just a good
> programming practice....
>
> I am sure it shouldnt be that much of an effort to implement what i need,
> and hopefully someone has a better suggestion in this case..
>
> jwcarman wrote:
>>
>> How often does an exception happen?  Exceptions are supposed to be
>> just that, exceptional.  Is it really worth your time/effort to code
>> for something that's not going to happen that often?
>>
>> On Wed, Sep 17, 2008 at 8:16 PM, mfs <fa...@gmail.com> wrote:
>>>
>>> Thanks for the followup....
>>>
>>> I understand what you are saying, but what i am not able to figure out,
>>> is
>>> the best way to communicate to the Search-Page THAT there was an
>>> EXCEPTION
>>> in the IDataProvider.iterator() or IDataProvider.size() methods (which
>>> contains all the back-end calls and is used/invoked by the DataView
>>> before
>>> rendering), now as i said i can have an empty-list-iterator (from the
>>> iterator method) returned if there is an Exception, but how to program
>>> the
>>> Page ? for it to populate the corresponding error message in the
>>> feedback-panel...
>>>
>>> Thanks in advance.
>>>
>>>
>>>
>>>
>>> jwcarman wrote:
>>>>
>>>> You could just always have a feedback panel on your page and if it
>>>> doesn't have anything to show, it'll just be invisible.  Then, if
>>>> something goes wrong, you just set an error-level message and it'll
>>>> show up on your feedback panel (don't forget to add the feedback panel
>>>> to your ajax response and tell it to output its markup id :).
>>>>
>>>> On Wed, Sep 17, 2008 at 7:54 PM, mfs <fa...@gmail.com> wrote:
>>>>>
>>>>> Hello Guys,
>>>>>
>>>>> I am trying to do something similar where i have a DataView (contained
>>>>> in
>>>>> a
>>>>> webmarkupContainer) which shows the results of a search. The whole
>>>>> implementation is ajax-based. Attached to the DataView is an
>>>>> IDataprovider
>>>>> implementation which is responsible for fetching the data from the
>>>>> database.
>>>>>
>>>>> Now i want to add this very feature, where in case of any
>>>>> Exception/Error
>>>>> in
>>>>> the back-end processing  (which is invoked by the DataProvider) of the
>>>>> search, I would want to add a feedback message on the same search-page,
>>>>> without being taken to the internal-error-page. As suggested I can
>>>>> certainly
>>>>> return an empty-list (from the IDataProvider.iterator()) or size=0
>>>>> (from
>>>>> the
>>>>> IDataProvider.size()) method which would still render the DataView
>>>>> component, but i am not sure how to tranform or in other words transfer
>>>>> the
>>>>> knowledge of this Exception to the Page itself.
>>>>>
>>>>> One ugly hack could be to pass on the FeedbackMessage Label component
>>>>> to
>>>>> the
>>>>> IDataProvider which based on the success/failure is populated with
>>>>> right
>>>>> message, and re-render the feedback-panel on every ajax-response, but
>>>>> that
>>>>> looks ugly, i dont want to couple the UI response to DataProvider which
>>>>> ideally should work independently of it.
>>>>>
>>>>> Please suggest..
>>>>>
>>>>> Thanks and Regards,
>>>>>
>>>>> Farhan.
>>>>>
>>>>> i want to display a feedback message in case there is an error at the
>>>>>
>>>>> Eelco Hillenius wrote:
>>>>>>
>>>>>>> The basic question was more if I have understood the requirement to
>>>>>>> always add a component if the HTML-template named one.
>>>>>>
>>>>>> Yes.
>>>>>>
>>>>>>> If so, if there
>>>>>>> was some pattern that had evolved for handling alternate or
>>>>>>> error-flows when building the component graph.
>>>>>>
>>>>>> Alternative flows can be handled using panels or fragments possibly
>>>>>> combined with component replacements.
>>>>>>
>>>>>> As for the error-flow, and I don't really see why:
>>>>>>
>>>>>> try {
>>>>>>   ...query the database and build the provider and dataview
>>>>>> } catch (SQLException e) {
>>>>>>  feedback.error("Very bad things happened");
>>>>>>  // What to do here??
>>>>>> }
>>>>>>
>>>>>> should generate a different component structure rather than an error
>>>>>> page.
>>>>>>
>>>>>> Eelco
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543530.html
>>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543753.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19545856.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by mfs <fa...@gmail.com>.
Well you were right, but you then exceptions are for those exceptional
scenarios, and we still want to cater those. I would say just a good
programming practice....

I am sure it shouldnt be that much of an effort to implement what i need,
and hopefully someone has a better suggestion in this case..

jwcarman wrote:
> 
> How often does an exception happen?  Exceptions are supposed to be
> just that, exceptional.  Is it really worth your time/effort to code
> for something that's not going to happen that often?
> 
> On Wed, Sep 17, 2008 at 8:16 PM, mfs <fa...@gmail.com> wrote:
>>
>> Thanks for the followup....
>>
>> I understand what you are saying, but what i am not able to figure out,
>> is
>> the best way to communicate to the Search-Page THAT there was an
>> EXCEPTION
>> in the IDataProvider.iterator() or IDataProvider.size() methods (which
>> contains all the back-end calls and is used/invoked by the DataView
>> before
>> rendering), now as i said i can have an empty-list-iterator (from the
>> iterator method) returned if there is an Exception, but how to program
>> the
>> Page ? for it to populate the corresponding error message in the
>> feedback-panel...
>>
>> Thanks in advance.
>>
>>
>>
>>
>> jwcarman wrote:
>>>
>>> You could just always have a feedback panel on your page and if it
>>> doesn't have anything to show, it'll just be invisible.  Then, if
>>> something goes wrong, you just set an error-level message and it'll
>>> show up on your feedback panel (don't forget to add the feedback panel
>>> to your ajax response and tell it to output its markup id :).
>>>
>>> On Wed, Sep 17, 2008 at 7:54 PM, mfs <fa...@gmail.com> wrote:
>>>>
>>>> Hello Guys,
>>>>
>>>> I am trying to do something similar where i have a DataView (contained
>>>> in
>>>> a
>>>> webmarkupContainer) which shows the results of a search. The whole
>>>> implementation is ajax-based. Attached to the DataView is an
>>>> IDataprovider
>>>> implementation which is responsible for fetching the data from the
>>>> database.
>>>>
>>>> Now i want to add this very feature, where in case of any
>>>> Exception/Error
>>>> in
>>>> the back-end processing  (which is invoked by the DataProvider) of the
>>>> search, I would want to add a feedback message on the same search-page,
>>>> without being taken to the internal-error-page. As suggested I can
>>>> certainly
>>>> return an empty-list (from the IDataProvider.iterator()) or size=0
>>>> (from
>>>> the
>>>> IDataProvider.size()) method which would still render the DataView
>>>> component, but i am not sure how to tranform or in other words transfer
>>>> the
>>>> knowledge of this Exception to the Page itself.
>>>>
>>>> One ugly hack could be to pass on the FeedbackMessage Label component
>>>> to
>>>> the
>>>> IDataProvider which based on the success/failure is populated with
>>>> right
>>>> message, and re-render the feedback-panel on every ajax-response, but
>>>> that
>>>> looks ugly, i dont want to couple the UI response to DataProvider which
>>>> ideally should work independently of it.
>>>>
>>>> Please suggest..
>>>>
>>>> Thanks and Regards,
>>>>
>>>> Farhan.
>>>>
>>>> i want to display a feedback message in case there is an error at the
>>>>
>>>> Eelco Hillenius wrote:
>>>>>
>>>>>> The basic question was more if I have understood the requirement to
>>>>>> always add a component if the HTML-template named one.
>>>>>
>>>>> Yes.
>>>>>
>>>>>> If so, if there
>>>>>> was some pattern that had evolved for handling alternate or
>>>>>> error-flows when building the component graph.
>>>>>
>>>>> Alternative flows can be handled using panels or fragments possibly
>>>>> combined with component replacements.
>>>>>
>>>>> As for the error-flow, and I don't really see why:
>>>>>
>>>>> try {
>>>>>   ...query the database and build the provider and dataview
>>>>> } catch (SQLException e) {
>>>>>  feedback.error("Very bad things happened");
>>>>>  // What to do here??
>>>>> }
>>>>>
>>>>> should generate a different component structure rather than an error
>>>>> page.
>>>>>
>>>>> Eelco
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543530.html
>>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543753.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19545856.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by James Carman <ja...@carmanconsulting.com>.
How often does an exception happen?  Exceptions are supposed to be
just that, exceptional.  Is it really worth your time/effort to code
for something that's not going to happen that often?

On Wed, Sep 17, 2008 at 8:16 PM, mfs <fa...@gmail.com> wrote:
>
> Thanks for the followup....
>
> I understand what you are saying, but what i am not able to figure out, is
> the best way to communicate to the Search-Page THAT there was an EXCEPTION
> in the IDataProvider.iterator() or IDataProvider.size() methods (which
> contains all the back-end calls and is used/invoked by the DataView before
> rendering), now as i said i can have an empty-list-iterator (from the
> iterator method) returned if there is an Exception, but how to program the
> Page ? for it to populate the corresponding error message in the
> feedback-panel...
>
> Thanks in advance.
>
>
>
>
> jwcarman wrote:
>>
>> You could just always have a feedback panel on your page and if it
>> doesn't have anything to show, it'll just be invisible.  Then, if
>> something goes wrong, you just set an error-level message and it'll
>> show up on your feedback panel (don't forget to add the feedback panel
>> to your ajax response and tell it to output its markup id :).
>>
>> On Wed, Sep 17, 2008 at 7:54 PM, mfs <fa...@gmail.com> wrote:
>>>
>>> Hello Guys,
>>>
>>> I am trying to do something similar where i have a DataView (contained in
>>> a
>>> webmarkupContainer) which shows the results of a search. The whole
>>> implementation is ajax-based. Attached to the DataView is an
>>> IDataprovider
>>> implementation which is responsible for fetching the data from the
>>> database.
>>>
>>> Now i want to add this very feature, where in case of any Exception/Error
>>> in
>>> the back-end processing  (which is invoked by the DataProvider) of the
>>> search, I would want to add a feedback message on the same search-page,
>>> without being taken to the internal-error-page. As suggested I can
>>> certainly
>>> return an empty-list (from the IDataProvider.iterator()) or size=0 (from
>>> the
>>> IDataProvider.size()) method which would still render the DataView
>>> component, but i am not sure how to tranform or in other words transfer
>>> the
>>> knowledge of this Exception to the Page itself.
>>>
>>> One ugly hack could be to pass on the FeedbackMessage Label component to
>>> the
>>> IDataProvider which based on the success/failure is populated with right
>>> message, and re-render the feedback-panel on every ajax-response, but
>>> that
>>> looks ugly, i dont want to couple the UI response to DataProvider which
>>> ideally should work independently of it.
>>>
>>> Please suggest..
>>>
>>> Thanks and Regards,
>>>
>>> Farhan.
>>>
>>> i want to display a feedback message in case there is an error at the
>>>
>>> Eelco Hillenius wrote:
>>>>
>>>>> The basic question was more if I have understood the requirement to
>>>>> always add a component if the HTML-template named one.
>>>>
>>>> Yes.
>>>>
>>>>> If so, if there
>>>>> was some pattern that had evolved for handling alternate or
>>>>> error-flows when building the component graph.
>>>>
>>>> Alternative flows can be handled using panels or fragments possibly
>>>> combined with component replacements.
>>>>
>>>> As for the error-flow, and I don't really see why:
>>>>
>>>> try {
>>>>   ...query the database and build the provider and dataview
>>>> } catch (SQLException e) {
>>>>  feedback.error("Very bad things happened");
>>>>  // What to do here??
>>>> }
>>>>
>>>> should generate a different component structure rather than an error
>>>> page.
>>>>
>>>> Eelco
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>>>
>>> --
>>> View this message in context:
>>> http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543530.html
>>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543753.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by mfs <fa...@gmail.com>.
Thanks for the followup....

I understand what you are saying, but what i am not able to figure out, is
the best way to communicate to the Search-Page THAT there was an EXCEPTION
in the IDataProvider.iterator() or IDataProvider.size() methods (which
contains all the back-end calls and is used/invoked by the DataView before
rendering), now as i said i can have an empty-list-iterator (from the
iterator method) returned if there is an Exception, but how to program the
Page ? for it to populate the corresponding error message in the
feedback-panel...

Thanks in advance.




jwcarman wrote:
> 
> You could just always have a feedback panel on your page and if it
> doesn't have anything to show, it'll just be invisible.  Then, if
> something goes wrong, you just set an error-level message and it'll
> show up on your feedback panel (don't forget to add the feedback panel
> to your ajax response and tell it to output its markup id :).
> 
> On Wed, Sep 17, 2008 at 7:54 PM, mfs <fa...@gmail.com> wrote:
>>
>> Hello Guys,
>>
>> I am trying to do something similar where i have a DataView (contained in
>> a
>> webmarkupContainer) which shows the results of a search. The whole
>> implementation is ajax-based. Attached to the DataView is an
>> IDataprovider
>> implementation which is responsible for fetching the data from the
>> database.
>>
>> Now i want to add this very feature, where in case of any Exception/Error
>> in
>> the back-end processing  (which is invoked by the DataProvider) of the
>> search, I would want to add a feedback message on the same search-page,
>> without being taken to the internal-error-page. As suggested I can
>> certainly
>> return an empty-list (from the IDataProvider.iterator()) or size=0 (from
>> the
>> IDataProvider.size()) method which would still render the DataView
>> component, but i am not sure how to tranform or in other words transfer
>> the
>> knowledge of this Exception to the Page itself.
>>
>> One ugly hack could be to pass on the FeedbackMessage Label component to
>> the
>> IDataProvider which based on the success/failure is populated with right
>> message, and re-render the feedback-panel on every ajax-response, but
>> that
>> looks ugly, i dont want to couple the UI response to DataProvider which
>> ideally should work independently of it.
>>
>> Please suggest..
>>
>> Thanks and Regards,
>>
>> Farhan.
>>
>> i want to display a feedback message in case there is an error at the
>>
>> Eelco Hillenius wrote:
>>>
>>>> The basic question was more if I have understood the requirement to
>>>> always add a component if the HTML-template named one.
>>>
>>> Yes.
>>>
>>>> If so, if there
>>>> was some pattern that had evolved for handling alternate or
>>>> error-flows when building the component graph.
>>>
>>> Alternative flows can be handled using panels or fragments possibly
>>> combined with component replacements.
>>>
>>> As for the error-flow, and I don't really see why:
>>>
>>> try {
>>>   ...query the database and build the provider and dataview
>>> } catch (SQLException e) {
>>>  feedback.error("Very bad things happened");
>>>  // What to do here??
>>> }
>>>
>>> should generate a different component structure rather than an error
>>> page.
>>>
>>> Eelco
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543530.html
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543753.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by James Carman <ja...@carmanconsulting.com>.
You could just always have a feedback panel on your page and if it
doesn't have anything to show, it'll just be invisible.  Then, if
something goes wrong, you just set an error-level message and it'll
show up on your feedback panel (don't forget to add the feedback panel
to your ajax response and tell it to output its markup id :).

On Wed, Sep 17, 2008 at 7:54 PM, mfs <fa...@gmail.com> wrote:
>
> Hello Guys,
>
> I am trying to do something similar where i have a DataView (contained in a
> webmarkupContainer) which shows the results of a search. The whole
> implementation is ajax-based. Attached to the DataView is an IDataprovider
> implementation which is responsible for fetching the data from the database.
>
> Now i want to add this very feature, where in case of any Exception/Error in
> the back-end processing  (which is invoked by the DataProvider) of the
> search, I would want to add a feedback message on the same search-page,
> without being taken to the internal-error-page. As suggested I can certainly
> return an empty-list (from the IDataProvider.iterator()) or size=0 (from the
> IDataProvider.size()) method which would still render the DataView
> component, but i am not sure how to tranform or in other words transfer the
> knowledge of this Exception to the Page itself.
>
> One ugly hack could be to pass on the FeedbackMessage Label component to the
> IDataProvider which based on the success/failure is populated with right
> message, and re-render the feedback-panel on every ajax-response, but that
> looks ugly, i dont want to couple the UI response to DataProvider which
> ideally should work independently of it.
>
> Please suggest..
>
> Thanks and Regards,
>
> Farhan.
>
> i want to display a feedback message in case there is an error at the
>
> Eelco Hillenius wrote:
>>
>>> The basic question was more if I have understood the requirement to
>>> always add a component if the HTML-template named one.
>>
>> Yes.
>>
>>> If so, if there
>>> was some pattern that had evolved for handling alternate or
>>> error-flows when building the component graph.
>>
>> Alternative flows can be handled using panels or fragments possibly
>> combined with component replacements.
>>
>> As for the error-flow, and I don't really see why:
>>
>> try {
>>   ...query the database and build the provider and dataview
>> } catch (SQLException e) {
>>  feedback.error("Very bad things happened");
>>  // What to do here??
>> }
>>
>> should generate a different component structure rather than an error page.
>>
>> Eelco
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543530.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by Igor Vaynberg <ig...@gmail.com>.
a) interface ierrorlistener { void error(string msg); }
b) abstract class errorreportingdataprovier implements idataprovider {
   private component owner; // setter
   protected abstract internaliterator(int s, int c);
   protected abstract void reporterror(ierrorlistener l, exception e);
   public iterator iterator(int s,int c) {
      try { internaliterator(s,c); }
      catch (exception e) {
         ierrorlistener l=owner.findancestor(ierrorlistener.class);
         reporterror(l,e);
         return new emptyiterator();
       }
    }
c) let your dataprovider extend the one in (b)
d) make sure whatever it is you use to render the message renders
after the dataview.

-igor

On Wed, Sep 17, 2008 at 4:54 PM, mfs <fa...@gmail.com> wrote:
>
> Hello Guys,
>
> I am trying to do something similar where i have a DataView (contained in a
> webmarkupContainer) which shows the results of a search. The whole
> implementation is ajax-based. Attached to the DataView is an IDataprovider
> implementation which is responsible for fetching the data from the database.
>
> Now i want to add this very feature, where in case of any Exception/Error in
> the back-end processing  (which is invoked by the DataProvider) of the
> search, I would want to add a feedback message on the same search-page,
> without being taken to the internal-error-page. As suggested I can certainly
> return an empty-list (from the IDataProvider.iterator()) or size=0 (from the
> IDataProvider.size()) method which would still render the DataView
> component, but i am not sure how to tranform or in other words transfer the
> knowledge of this Exception to the Page itself.
>
> One ugly hack could be to pass on the FeedbackMessage Label component to the
> IDataProvider which based on the success/failure is populated with right
> message, and re-render the feedback-panel on every ajax-response, but that
> looks ugly, i dont want to couple the UI response to DataProvider which
> ideally should work independently of it.
>
> Please suggest..
>
> Thanks and Regards,
>
> Farhan.
>
> i want to display a feedback message in case there is an error at the
>
> Eelco Hillenius wrote:
>>
>>> The basic question was more if I have understood the requirement to
>>> always add a component if the HTML-template named one.
>>
>> Yes.
>>
>>> If so, if there
>>> was some pattern that had evolved for handling alternate or
>>> error-flows when building the component graph.
>>
>> Alternative flows can be handled using panels or fragments possibly
>> combined with component replacements.
>>
>> As for the error-flow, and I don't really see why:
>>
>> try {
>>   ...query the database and build the provider and dataview
>> } catch (SQLException e) {
>>  feedback.error("Very bad things happened");
>>  // What to do here??
>> }
>>
>> should generate a different component structure rather than an error page.
>>
>> Eelco
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> --
> View this message in context: http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543530.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by mfs <fa...@gmail.com>.
Hello Guys,

I am trying to do something similar where i have a DataView (contained in a
webmarkupContainer) which shows the results of a search. The whole
implementation is ajax-based. Attached to the DataView is an IDataprovider
implementation which is responsible for fetching the data from the database. 

Now i want to add this very feature, where in case of any Exception/Error in
the back-end processing  (which is invoked by the DataProvider) of the
search, I would want to add a feedback message on the same search-page,
without being taken to the internal-error-page. As suggested I can certainly
return an empty-list (from the IDataProvider.iterator()) or size=0 (from the
IDataProvider.size()) method which would still render the DataView
component, but i am not sure how to tranform or in other words transfer the
knowledge of this Exception to the Page itself. 

One ugly hack could be to pass on the FeedbackMessage Label component to the
IDataProvider which based on the success/failure is populated with right
message, and re-render the feedback-panel on every ajax-response, but that
looks ugly, i dont want to couple the UI response to DataProvider which
ideally should work independently of it.

Please suggest..

Thanks and Regards,

Farhan.

i want to display a feedback message in case there is an error at the 

Eelco Hillenius wrote:
> 
>> The basic question was more if I have understood the requirement to
>> always add a component if the HTML-template named one.
> 
> Yes.
> 
>> If so, if there
>> was some pattern that had evolved for handling alternate or
>> error-flows when building the component graph.
> 
> Alternative flows can be handled using panels or fragments possibly
> combined with component replacements.
> 
> As for the error-flow, and I don't really see why:
> 
> try {
>   ...query the database and build the provider and dataview
> } catch (SQLException e) {
>  feedback.error("Very bad things happened");
>  // What to do here??
> }
> 
> should generate a different component structure rather than an error page.
> 
> Eelco
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/newbie%3A-best-practice-for-not-rendering-component--tp12070364p19543530.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by Eelco Hillenius <ee...@gmail.com>.
> The basic question was more if I have understood the requirement to
> always add a component if the HTML-template named one.

Yes.

> If so, if there
> was some pattern that had evolved for handling alternate or
> error-flows when building the component graph.

Alternative flows can be handled using panels or fragments possibly
combined with component replacements.

As for the error-flow, and I don't really see why:

try {
  ...query the database and build the provider and dataview
} catch (SQLException e) {
 feedback.error("Very bad things happened");
 // What to do here??
}

should generate a different component structure rather than an error page.

Eelco

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by Dipu Seminlal <di...@googlemail.com>.
Yes you will have to add the component, if your HTML template named one.

Regards
Dipu




On 8/9/07, Johan Maasing <jm...@gmail.com> wrote:
>
> Thank you for your replies. Yes I can create an empty "dummy" model if
> I fail to talk to the back-end, it also sounds like good practice to
> put that handling in the model.
> The basic question was more if I have understood the requirement to
> always add a component if the HTML-template named one. If so, if there
> was some pattern that had evolved for handling alternate or
> error-flows when building the component graph.
>
>
> On 8/9/07, Dipu Seminlal <di...@googlemail.com> wrote:
> > Can't you return Collections.EMPTY_LIST.iterator() from the dataprovider
> > when an exception happens
> > and also set the visibility of the data view based on the size -
> > dataview.setVisible(yourdataprovider.size()>0)
> >
> > Regards
> > Dipu
> >
> >
> > On 8/9/07, Johan Maasing <jm...@gmail.com> wrote:
> > >
> > > I am rather new to wicket, coming from a Tapestry angle. Anyway, my
> > > question is rather basic.
> > > I gather that all components on a page must be rendered?
> > > Suppose I have a common dataview with a dataprovider on a page, basic
> > > CRUD-stuff. My page constructor looks like this:
> > >
> > > try {
> > >    ...query the database and build the provider and dataview
> > > } catch (SQLException e) {
> > >   feedback.error("Very bad things happened");
> > >   // What to do here??
> > > }
> > >
> > > What is the best practice for removing/disabling components in the
> > > catch clause? I can not create the dataview (called "dataview" in the
> > > HTML) since the backend has died but wicket needs a component there?
> > >
> > > Currently I do somehting like this
> > >
> > > } catch (Exception e) {
> > >   add(new Label("dataview", "").setVisible(false));
> > > }
> > >
> > > and that works fine but it seems a bit un-DRY to have to add dummy
> > > components for the error case. Is my understanding correct?
> > >
> > > Cheers,
> > > /Johan
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: newbie: best practice for not rendering component?

Posted by Johan Maasing <jm...@gmail.com>.
Thank you for your replies. Yes I can create an empty "dummy" model if
I fail to talk to the back-end, it also sounds like good practice to
put that handling in the model.
The basic question was more if I have understood the requirement to
always add a component if the HTML-template named one. If so, if there
was some pattern that had evolved for handling alternate or
error-flows when building the component graph.


On 8/9/07, Dipu Seminlal <di...@googlemail.com> wrote:
> Can't you return Collections.EMPTY_LIST.iterator() from the dataprovider
> when an exception happens
> and also set the visibility of the data view based on the size -
> dataview.setVisible(yourdataprovider.size()>0)
>
> Regards
> Dipu
>
>
> On 8/9/07, Johan Maasing <jm...@gmail.com> wrote:
> >
> > I am rather new to wicket, coming from a Tapestry angle. Anyway, my
> > question is rather basic.
> > I gather that all components on a page must be rendered?
> > Suppose I have a common dataview with a dataprovider on a page, basic
> > CRUD-stuff. My page constructor looks like this:
> >
> > try {
> >    ...query the database and build the provider and dataview
> > } catch (SQLException e) {
> >   feedback.error("Very bad things happened");
> >   // What to do here??
> > }
> >
> > What is the best practice for removing/disabling components in the
> > catch clause? I can not create the dataview (called "dataview" in the
> > HTML) since the backend has died but wicket needs a component there?
> >
> > Currently I do somehting like this
> >
> > } catch (Exception e) {
> >   add(new Label("dataview", "").setVisible(false));
> > }
> >
> > and that works fine but it seems a bit un-DRY to have to add dummy
> > components for the error case. Is my understanding correct?
> >
> > Cheers,
> > /Johan
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: newbie: best practice for not rendering component?

Posted by Dipu Seminlal <di...@googlemail.com>.
Can't you return Collections.EMPTY_LIST.iterator() from the dataprovider
when an exception happens
and also set the visibility of the data view based on the size -
dataview.setVisible(yourdataprovider.size()>0)

Regards
Dipu


On 8/9/07, Johan Maasing <jm...@gmail.com> wrote:
>
> I am rather new to wicket, coming from a Tapestry angle. Anyway, my
> question is rather basic.
> I gather that all components on a page must be rendered?
> Suppose I have a common dataview with a dataprovider on a page, basic
> CRUD-stuff. My page constructor looks like this:
>
> try {
>    ...query the database and build the provider and dataview
> } catch (SQLException e) {
>   feedback.error("Very bad things happened");
>   // What to do here??
> }
>
> What is the best practice for removing/disabling components in the
> catch clause? I can not create the dataview (called "dataview" in the
> HTML) since the backend has died but wicket needs a component there?
>
> Currently I do somehting like this
>
> } catch (Exception e) {
>   add(new Label("dataview", "").setVisible(false));
> }
>
> and that works fine but it seems a bit un-DRY to have to add dummy
> components for the error case. Is my understanding correct?
>
> Cheers,
> /Johan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: newbie: best practice for not rendering component?

Posted by Matej Knopp <ma...@gmail.com>.
First, i'd recommend you overriding isVisible method instead of
setting the visible flag, it gives you more flexibility. Second, you
shouldn't query the database in constructor, implement the
IDataProvider and let dataview deal with case when there are no items
in datatable. If you return empty list the dataview will be empty too.

-Matej

On 8/9/07, Johan Maasing <jm...@gmail.com> wrote:
> I am rather new to wicket, coming from a Tapestry angle. Anyway, my
> question is rather basic.
> I gather that all components on a page must be rendered?
> Suppose I have a common dataview with a dataprovider on a page, basic
> CRUD-stuff. My page constructor looks like this:
>
> try {
>    ...query the database and build the provider and dataview
> } catch (SQLException e) {
>   feedback.error("Very bad things happened");
>   // What to do here??
> }
>
> What is the best practice for removing/disabling components in the
> catch clause? I can not create the dataview (called "dataview" in the
> HTML) since the backend has died but wicket needs a component there?
>
> Currently I do somehting like this
>
> } catch (Exception e) {
>   add(new Label("dataview", "").setVisible(false));
> }
>
> and that works fine but it seems a bit un-DRY to have to add dummy
> components for the error case. Is my understanding correct?
>
> Cheers,
> /Johan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org