Re: Question on component hierarchy
Good, this suggests that having a Panel as a boilerplate and then turning off the parts that are not required is a recognised pattern. Otherwise I could foresee the proliferation of home made components reaching a point where it became a burden to know which one to use. On Wed, Apr 9, 2008 at 7:57 AM, John Patterson [EMAIL PROTECTED] wrote: You would also need to setVisible(false) on the WMC or wicket would throw an exception at the missing child components. I use a simple class InvisibleComponent for this. Eric Rotick wrote: One more thing that was suggested in class. Is it possible to define a Panel which had all suitable and appropriate sub components and then to no-op the ones that were not needed? So in the earlier example there could be a panel wicket:panel /wicket:panel and if the image was not needed it could be no-op'ed out by defining a WebMarkupContainer but with no children. On Tue, Apr 8, 2008 at 6:53 PM, Eric Rotick [EMAIL PROTECTED] wrote: Many thanks for the clarification. As I am about to start teaching the rudiments of Wicket to a project team I guess the teacher should know what they are talking about. On Tue, Apr 8, 2008 at 6:50 PM, Igor Vaynberg [EMAIL PROTECTED] wrote: you dont need a panel for the repeater itself. as for variable component hierarchy inside the repeater itself, you are correct: you have to either use a panel or a fragment. -igor On Tue, Apr 8, 2008 at 9:37 AM, Eric Rotick [EMAIL PROTECTED] wrote: I thought I understood the component hierarchy but then I started to tell the guys about it and now I'm not so sure. If the markup defines a hierarchy as A contains B contains C, in effect, this means that C is added to B which is added to A. If we expand B to be more complex we can use maybe a Panel which we identify as B but inside it is BA , BB and so on. So, all the time there is a direct relationship between the wicket identified tags in the markup and the components in the code. Now we introduce a repeater of some kind and it appears that the component hierarchy is broken but it's not. So if C was a repeater and it had 4 children then the hierarchy is still A to B to C but within C there is C to C1, C to C2 and so on. Now, if we need to have a runtime variable amount of markup which is variable, not in terms of the same markup repeated but completely different markup based on some logic then we might define a Panel which handles the variation. This is fine but what if the contents of the Panel is also variable. In this case further Panels are needed until the variable requirements are covered. Now the rub; although there are components, such as WebMarkupContainer which can be used to group components, the use of any component which is not 'transparent' must have the related wicket:id in some markup somewhere. So, lets take an example where we have a list of items which can be just text or a link which has an optional image. It seems that I have to define panels for :- - wrapper panel for the list - a link with it's text - a link with it's text and image So we have markup such as wicket:panel ul li wicket:id=items/ /ul /wicket:panel wicket:panel /wicket:panel wicket:panel /wicket:panel Have I got this correct or have I gone astray somewhere? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/Question-on-component-hierarchy-tp16567888p16580692.html Sent from the Wicket - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Question on component hierarchy
I thought I understood the component hierarchy but then I started to tell the guys about it and now I'm not so sure. If the markup defines a hierarchy as A contains B contains C, in effect, this means that C is added to B which is added to A. If we expand B to be more complex we can use maybe a Panel which we identify as B but inside it is BA , BB and so on. So, all the time there is a direct relationship between the wicket identified tags in the markup and the components in the code. Now we introduce a repeater of some kind and it appears that the component hierarchy is broken but it's not. So if C was a repeater and it had 4 children then the hierarchy is still A to B to C but within C there is C to C1, C to C2 and so on. Now, if we need to have a runtime variable amount of markup which is variable, not in terms of the same markup repeated but completely different markup based on some logic then we might define a Panel which handles the variation. This is fine but what if the contents of the Panel is also variable. In this case further Panels are needed until the variable requirements are covered. Now the rub; although there are components, such as WebMarkupContainer which can be used to group components, the use of any component which is not 'transparent' must have the related wicket:id in some markup somewhere. So, lets take an example where we have a list of items which can be just text or a link which has an optional image. It seems that I have to define panels for :- - wrapper panel for the list - a link with it's text - a link with it's text and image So we have markup such as wicket:panel ul li wicket:id=items/ /ul /wicket:panel wicket:panel span wicket:id=link span wicket:id=text/ /span /wicket:panel wicket:panel span wicket:id=link span wicket:id=text/ img wicket:id=image/ /span /wicket:panel Have I got this correct or have I gone astray somewhere?
Re: Question on component hierarchy
Many thanks for the clarification. As I am about to start teaching the rudiments of Wicket to a project team I guess the teacher should know what they are talking about. On Tue, Apr 8, 2008 at 6:50 PM, Igor Vaynberg [EMAIL PROTECTED] wrote: you dont need a panel for the repeater itself. as for variable component hierarchy inside the repeater itself, you are correct: you have to either use a panel or a fragment. -igor On Tue, Apr 8, 2008 at 9:37 AM, Eric Rotick [EMAIL PROTECTED] wrote: I thought I understood the component hierarchy but then I started to tell the guys about it and now I'm not so sure. If the markup defines a hierarchy as A contains B contains C, in effect, this means that C is added to B which is added to A. If we expand B to be more complex we can use maybe a Panel which we identify as B but inside it is BA , BB and so on. So, all the time there is a direct relationship between the wicket identified tags in the markup and the components in the code. Now we introduce a repeater of some kind and it appears that the component hierarchy is broken but it's not. So if C was a repeater and it had 4 children then the hierarchy is still A to B to C but within C there is C to C1, C to C2 and so on. Now, if we need to have a runtime variable amount of markup which is variable, not in terms of the same markup repeated but completely different markup based on some logic then we might define a Panel which handles the variation. This is fine but what if the contents of the Panel is also variable. In this case further Panels are needed until the variable requirements are covered. Now the rub; although there are components, such as WebMarkupContainer which can be used to group components, the use of any component which is not 'transparent' must have the related wicket:id in some markup somewhere. So, lets take an example where we have a list of items which can be just text or a link which has an optional image. It seems that I have to define panels for :- - wrapper panel for the list - a link with it's text - a link with it's text and image So we have markup such as wicket:panel ul li wicket:id=items/ /ul /wicket:panel wicket:panel span wicket:id=link span wicket:id=text/ /span /wicket:panel wicket:panel span wicket:id=link span wicket:id=text/ img wicket:id=image/ /span /wicket:panel Have I got this correct or have I gone astray somewhere? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Question on component hierarchy
One more thing that was suggested in class. Is it possible to define a Panel which had all suitable and appropriate sub components and then to no-op the ones that were not needed? So in the earlier example there could be a panel wicket:panel span wicket:id=link span wicket:id=text/ img wicket:id=image/ /span /wicket:panel and if the image was not needed it could be no-op'ed out by defining a WebMarkupContainer but with no children. On Tue, Apr 8, 2008 at 6:53 PM, Eric Rotick [EMAIL PROTECTED] wrote: Many thanks for the clarification. As I am about to start teaching the rudiments of Wicket to a project team I guess the teacher should know what they are talking about. On Tue, Apr 8, 2008 at 6:50 PM, Igor Vaynberg [EMAIL PROTECTED] wrote: you dont need a panel for the repeater itself. as for variable component hierarchy inside the repeater itself, you are correct: you have to either use a panel or a fragment. -igor On Tue, Apr 8, 2008 at 9:37 AM, Eric Rotick [EMAIL PROTECTED] wrote: I thought I understood the component hierarchy but then I started to tell the guys about it and now I'm not so sure. If the markup defines a hierarchy as A contains B contains C, in effect, this means that C is added to B which is added to A. If we expand B to be more complex we can use maybe a Panel which we identify as B but inside it is BA , BB and so on. So, all the time there is a direct relationship between the wicket identified tags in the markup and the components in the code. Now we introduce a repeater of some kind and it appears that the component hierarchy is broken but it's not. So if C was a repeater and it had 4 children then the hierarchy is still A to B to C but within C there is C to C1, C to C2 and so on. Now, if we need to have a runtime variable amount of markup which is variable, not in terms of the same markup repeated but completely different markup based on some logic then we might define a Panel which handles the variation. This is fine but what if the contents of the Panel is also variable. In this case further Panels are needed until the variable requirements are covered. Now the rub; although there are components, such as WebMarkupContainer which can be used to group components, the use of any component which is not 'transparent' must have the related wicket:id in some markup somewhere. So, lets take an example where we have a list of items which can be just text or a link which has an optional image. It seems that I have to define panels for :- - wrapper panel for the list - a link with it's text - a link with it's text and image So we have markup such as wicket:panel ul li wicket:id=items/ /ul /wicket:panel wicket:panel span wicket:id=link span wicket:id=text/ /span /wicket:panel wicket:panel span wicket:id=link span wicket:id=text/ img wicket:id=image/ /span /wicket:panel Have I got this correct or have I gone astray somewhere? - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DateTextField and DatePicker are not using the same date pattern
Further to this I've now checked the source and the DatePicker does correctly pick up the date format from the DateTextField or, alternatively, an overridden getDatePattern also works. It seems to be going wrong when the date is sent from the DatePicker back to the DateTextField via the onchange Javascript event handler. I've not yet figured out how this works yet. Has anyone used the DatePicker in this way to confirm that it does or does not work as expected? On Fri, Mar 28, 2008 at 1:18 PM, Eric Rotick [EMAIL PROTECTED] wrote: I have a situation where the DateTextField and DatePicker are not using the same date pattern although I set them to the same value. If I have an existing date in the model then it is formatted correctly and that date is also inherited correctly when the DatePicker opens. When I then select a different date in the DatePicker the correct date value is returned to the DateTextField but the format it wrong. Then if I submit the form I get an error on the DateTextField. For example, if I select a date of 28/Mar/2008 in the DatePicker it gets returned to the DateTextField as 28/3/2008. Any ideas? import org.apache.wicket.datetime.markup.html.form.DateTextField; import org.apache.wicket.datetime.PatternDateConverter; import org.apache.wicket.extensions.yui.calendar.DatePicker; ... public class DateField extends Panel { public DateField( String id, boolean readonly, IField field, IModel model ) { super( id ); final String dateFormat = dd/MMM/; PatternDateConverter pdc = new PatternDateConverter( dateFormat, true ); DateTextField dtf = new DateTextField( textValue, new NamedAccessorModel( model, field.getModelName( ) ), pdc ); add( dtf ); DatePicker dp = new DatePicker( ) { protected boolean enableMonthYearSelection( ) { return true; } protected String getDatePattern( ) { return dateFormat; } }; dtf.add( dp ); } }
Re: TextField returning a null
I guess, if this was a real issue then more users would have reported it. However, as a TextField is such an innocent component then any confusing behaviour should be addressed. Maintaining a common behaviour of setConvertEmptyInputStringToNull would do that and your proposed solution looks good. One thing which was confusing from the javadocs level is the implication that the setting of a type is defaulted; i.e. public TextField( String id, Class type ) { super( id ); setType( type ); ... } public TextField( String id ) { super( id ); Class type = workOutTypeFromModelIfPossible( ); if( type == null ) { type = String.class; } setType( type ); ... } In other words, there is always a type set unless the model is one which does not allow for it to be derived in which case String is assumed as in the FormComponent javadocs for setType. Eric. On Mon, Mar 31, 2008 at 1:37 PM, Johan Compagner [EMAIL PROTECTED] wrote: Ok i guess if if quickly look at the code. If you dont do your own converter then it defaults i guess to the DefaultConverter that does this: public Object convertToObject(String value, Locale locale) { if (value == null) { return null; } if (.equals(value)) { if (((Class)type.get()) == String.class) { return ; } return null; } So if it is a String class and the input is it does return we could change this: final IConverter converter = getConverter(getType()); try { convertedInput = converter.convertToObject(getInput(), getLocale()); } in FormComponent.. If it is of Type String then after the conversion we still check for the convert empty to null and do that.. Because now that boolean is of no use if you are setting the Type johan johan On Mon, Mar 31, 2008 at 2:34 PM, Johan Compagner [EMAIL PROTECTED] wrote: if you are setting the type The converter is called and not convertValue() i am still not really happy with this but for 1.3/1.4 this is the way it works And i guess the String converter that does String to String doesnt óok at that convert empty input to null value at all Do you have your own? johan On Mon, Mar 31, 2008 at 1:38 PM, Eric Rotick [EMAIL PROTECTED] wrote: I do have the type set and I've been reading WICKET-606 and I'm using 1.3.2and there is no converter and convertInput is not called. I've now written some code to show that there is a difference. form.add( new TextField( text1, new PropertyModel( this, text1 ) ) ); form.add( new TextField( text2, new PropertyModel( this, text2 ) ).setConvertEmptyInputStringToNull( true ) ); form.add( new TextField( text3, new PropertyModel( this, text3 ) ).setConvertEmptyInputStringToNull( false ) ); form.add( new TextField( text4, new PropertyModel( this, text4 ), String.class ) ); form.add( new TextField( text5, new PropertyModel( this, text5 ), String.class ).setConvertEmptyInputStringToNull( true ) ); form.add( new TextField( text6, new PropertyModel( this, text6 ), String.class ).setConvertEmptyInputStringToNull( false ) ); produces this Setting text1 to [null] Setting text2 to [null] Setting text3 to [] Setting text4 to [] Setting text5 to [] Setting text6 to [] So, - text1 and text2 are the same because setConvertEmptyInputStringToNull is true by default - text3 does what would be expected - text4 I'm not sure about - text5 and text6 are anomalous as either one or the other should produce a null I guess the main problem is that I'm not sure what is supposed to happen. I though that having set the type to String meant that the normal string processing took place and setConvertEmptyInputStringToNull did the job. As it is, I've learned more about how things work and I can overcome my problem. However, if anyone wants me to continue with this I would be happy to do so. Eric. On Fri, Mar 28, 2008 at 8:58 PM, Johan Compagner [EMAIL PROTECTED] wrote: Are you sure you dont have the type set? Is a converter used or is convertInput called? On 3/28/08, Eric Rotick [EMAIL PROTECTED] wrote: Hmm, it's not working for me. There's one other thing I spotted. The docs say that a TextField defaults to String.class even if it cannot work out the class from the model. My model is not one that allows for reflection to determine the class and initially all input to the TextField was being set as null even when there was some. As soon as I added the parameter to set the class to String it started saving strings correctly. I will have a look at the code to see if there's anything obvious. Eric
Dynamic creation of CSS
I have a requirement to allow users to change such things as colour, font etc. for certain markup. Currently this is all 'wrapped' by CSS ids/classes but the use of varying ids/classes seems wrong. The use case if for engineers viewing data from sensors. Some engineers require values below a certain value to be highlighted whereas other engineers want values above a certain value to be highlighted. The highlighting might means changing the font to bold, the background colour to yellow, the foreground colour to red and the surrounding box to double lines. I could have CSS classes of highlight1, highlight2 etc but read on. In essence the markup is exactly the same but for the highlighting rules so having a number of sub classed pages is not correct. In addition, the rules at which something may change might change at run time. For example, one particular engineer may be monitoring a system where a value is highlighted if it goes outside of a range and another highlight if the erroneous value has been out of range for an extended time period. Basically, each engineer can choose their own colour scheme. Also, for very complex situations an engineer would be overloaded by too much information. In these cases they dim down the non important data so that the important data becomes more prominent. OK, I could define a bigger set of CSS classes for each situation but each engineer has a different way of solving the viewing problem and the current system (not web based) does what they want. So, I think the solution lies in the dynamic generation of the CSS at run time from the database. I then thought I would create a small servlet to handle this but then, I already have Wicket running, maybe I should sub class Page and make a CssPage class. I need to have a pop at doing this in the future anyway for WML so the research would not be wasted. I was wondering if anyone had any experience or advice before I look into this in more detail. Eric.
Re: Dynamic creation of CSS
Where can I find out more about this approach? On Sat, Mar 29, 2008 at 2:07 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: if you need to do it dynamicly, you could just use the textressourcetemplate approach, something similar what I've done with the js in wicket input events (I stole the idea from the datepicker).. regards Nino Eric Rotick wrote: I have a requirement to allow users to change such things as colour, font etc. for certain markup. Currently this is all 'wrapped' by CSS ids/classes but the use of varying ids/classes seems wrong. The use case if for engineers viewing data from sensors. Some engineers require values below a certain value to be highlighted whereas other engineers want values above a certain value to be highlighted. The highlighting might means changing the font to bold, the background colour to yellow, the foreground colour to red and the surrounding box to double lines. I could have CSS classes of highlight1, highlight2 etc but read on. In essence the markup is exactly the same but for the highlighting rules so having a number of sub classed pages is not correct. In addition, the rules at which something may change might change at run time. For example, one particular engineer may be monitoring a system where a value is highlighted if it goes outside of a range and another highlight if the erroneous value has been out of range for an extended time period. Basically, each engineer can choose their own colour scheme. Also, for very complex situations an engineer would be overloaded by too much information. In these cases they dim down the non important data so that the important data becomes more prominent. OK, I could define a bigger set of CSS classes for each situation but each engineer has a different way of solving the viewing problem and the current system (not web based) does what they want. So, I think the solution lies in the dynamic generation of the CSS at run time from the database. I then thought I would create a small servlet to handle this but then, I already have Wicket running, maybe I should sub class Page and make a CssPage class. I need to have a pop at doing this in the future anyway for WML so the research would not be wasted. I was wondering if anyone had any experience or advice before I look into this in more detail. Eric. -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Dynamic creation of CSS
Now I see. I had not discovered these classes! I was hoping to avoid embedding the CSS within the HTML as this does not benefit from the size reduction that CSS separation gives. However, you've given me another idea. CSS allows for definitions to be overridden locally in each page so I could arrange for the differences to be embedded and leave the rest in the external CSS file. Actually, now I think of it, the idea of a 'standard' set would mean that I have to manage what is the default and what is the exception which is currently done in a hierarchical fashion which is pretty slow to resolve. The concept is that whenever a user changes anything to do with CSS the system recreated the file username.css which is then included in each page dynamically according to the user. The problem comes in where to write the file when in a war deployment situation. I could write it to a database but that still means it has to be 'produced' by the servlet engine and so we are back to the same question. Eric. On Sat, Mar 29, 2008 at 3:37 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-stuff-contrib-input-events essentially its this which are interesting: private String generateString(TextTemplate textTemplate) { // variables for the initialization script MapString, String variables = new HashMapString, String(); variables.put(disable_in_input, getDisable_in_input().toString()); variables.put(type, getType().toString()); variables.put(propagate, getPropagate().toString()); variables.put(target, getTarget()); textTemplate.interpolate(variables); return textTemplate.asString(); } in your case the text template could look like this: private final TextTemplate css = new PackagedTextTemplate( InputBehavior.class, mystyle.css); you notate in your text file like this: input { color:${color}; } Basicly you have a textfile and a map, when you interpolate the values the are replaced by what are inside your map... Ask if you have questions..:) regards Nino Eric Rotick wrote: Where can I find out more about this approach? On Sat, Mar 29, 2008 at 2:07 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: if you need to do it dynamicly, you could just use the textressourcetemplate approach, something similar what I've done with the js in wicket input events (I stole the idea from the datepicker).. regards Nino Eric Rotick wrote: I have a requirement to allow users to change such things as colour, font etc. for certain markup. Currently this is all 'wrapped' by CSS ids/classes but the use of varying ids/classes seems wrong. The use case if for engineers viewing data from sensors. Some engineers require values below a certain value to be highlighted whereas other engineers want values above a certain value to be highlighted. The highlighting might means changing the font to bold, the background colour to yellow, the foreground colour to red and the surrounding box to double lines. I could have CSS classes of highlight1, highlight2 etc but read on. In essence the markup is exactly the same but for the highlighting rules so having a number of sub classed pages is not correct. In addition, the rules at which something may change might change at run time. For example, one particular engineer may be monitoring a system where a value is highlighted if it goes outside of a range and another highlight if the erroneous value has been out of range for an extended time period. Basically, each engineer can choose their own colour scheme. Also, for very complex situations an engineer would be overloaded by too much information. In these cases they dim down the non important data so that the important data becomes more prominent. OK, I could define a bigger set of CSS classes for each situation but each engineer has a different way of solving the viewing problem and the current system (not web based) does what they want. So, I think the solution lies in the dynamic generation of the CSS at run time from the database. I then thought I would create a small servlet to handle this but then, I already have Wicket running, maybe I should sub class Page and make a CssPage class. I need to have a pop at doing this in the future anyway for WML so the research would not be wasted. I was wondering if anyone had any experience or advice before I look into this in more detail. Eric. -- -Wicket for love Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail
Re: Dynamic creation of CSS
Aha, I only covered the resources section of the ebook very briefly. Now having read it again I think this is exactly what I need. The caching that the browser does itself is good enough for this I think but I could add something later via AOP. Thanks for your help. Eric. On Sat, Mar 29, 2008 at 4:55 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: If you want to write it to a file you can do that too btw... regards Nino Saturnino Martinez Vazquez Wael wrote: You dont have to embed it, you could mount it as a resource... But still it needs to be generated. However you could cache this, it totally up to you.. regards Nin Eric Rotick wrote: Now I see. I had not discovered these classes! I was hoping to avoid embedding the CSS within the HTML as this does not benefit from the size reduction that CSS separation gives. However, you've given me another idea. CSS allows for definitions to be overridden locally in each page so I could arrange for the differences to be embedded and leave the rest in the external CSS file. Actually, now I think of it, the idea of a 'standard' set would mean that I have to manage what is the default and what is the exception which is currently done in a hierarchical fashion which is pretty slow to resolve. The concept is that whenever a user changes anything to do with CSS the system recreated the file username.css which is then included in each page dynamically according to the user. The problem comes in where to write the file when in a war deployment situation. I could write it to a database but that still means it has to be 'produced' by the servlet engine and so we are back to the same question. Eric. On Sat, Mar 29, 2008 at 3:37 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: http://wicketstuff.org/confluence/display/STUFFWIKI/wicket-stuff-contrib-input-events essentially its this which are interesting: private String generateString(TextTemplate textTemplate) { // variables for the initialization script MapString, String variables = new HashMapString, String(); variables.put(disable_in_input, getDisable_in_input().toString()); variables.put(type, getType().toString()); variables.put(propagate, getPropagate().toString()); variables.put(target, getTarget()); textTemplate.interpolate(variables); return textTemplate.asString(); } in your case the text template could look like this: private final TextTemplate css = new PackagedTextTemplate( InputBehavior.class, mystyle.css); you notate in your text file like this: input { color:${color}; } Basicly you have a textfile and a map, when you interpolate the values the are replaced by what are inside your map... Ask if you have questions..:) regards Nino Eric Rotick wrote: Where can I find out more about this approach? On Sat, Mar 29, 2008 at 2:07 PM, Nino Saturnino Martinez Vazquez Wael [EMAIL PROTECTED] wrote: if you need to do it dynamicly, you could just use the textressourcetemplate approach, something similar what I've done with the js in wicket input events (I stole the idea from the datepicker).. regards Nino Eric Rotick wrote: I have a requirement to allow users to change such things as colour, font etc. for certain markup. Currently this is all 'wrapped' by CSS ids/classes but the use of varying ids/classes seems wrong. The use case if for engineers viewing data from sensors. Some engineers require values below a certain value to be highlighted whereas other engineers want values above a certain value to be highlighted. The highlighting might means changing the font to bold, the background colour to yellow, the foreground colour to red and the surrounding box to double lines. I could have CSS classes of highlight1, highlight2 etc but read on. In essence the markup is exactly the same but for the highlighting rules so having a number of sub classed pages is not correct. In addition, the rules at which something may change might change at run time. For example, one particular engineer may be monitoring a system where a value is highlighted if it goes outside of a range and another highlight if the erroneous value has been out of range for an extended time period. Basically, each engineer can choose their own colour scheme. Also, for very complex situations an engineer would be overloaded by too much information. In these cases they dim down the non important data so that the important data becomes more prominent. OK, I could define a bigger set of CSS classes for each situation but each engineer has a different
TextField returning a null
I've just realised that the database is getting filled with columns of empty strings which then don't cause the 'not null' test to trip. The culprit is the TextField returning an empty string rather than a null. I can see there are some special considerations for returning a null and I want to understand how they will effect me. However, I've tried TexField.setConvertEmptyInputStringToNull( true ) with no effect and using new TextField( id ) { public boolean isInputNullable() { regturn true; } }; also with no effect. I'm assuming I'm not the first person to see this effect and I guess it's lack of understanding rather than some implicit behaviour but I can't find anything guiding on the subject. In this case, the string has no special formatting, it just needs to be stored verbatim in the database but the application logic in the backend uses an empty string in a different way than a null string and, yes, maybe the database should also have a column check but it doesn't at present. Any pointers?
Unsure about setResponsePage behaviour
I have a page with many buttons to do different things. I decided the best strategy was to setup the default page via a call to setReponsePage at the start of the page and then overrride this in the onSubmit method for each button. This appears not to work. However, if I set a value of the default page and override this value in the onSubmit method of each button and then only call the setResponsePage in the obSubmit method for the form then it works. I've also tried only making the call to setResponsePage in the onSubmit or onClick methods and this works. In summary, a call to setReponsePage outside of an onSubmit or onClick appears to have no effect. Is this correct and if so why? I can't find any docs to suggest not using this strategy.
Re: Unsure about setResponsePage behaviour
I have simplified the class and it behaves the same. public class SingleItemForm extends Panel { public SingleItemForm( String id, final boolean readonly, final ISingleDisplay display, final IModel model, final Page callingPage ) { super( id ); add( new FeedbackPanel (feedback ) ); final Form form = new Form( SingleItemFormName ); // Call here has no effect if( callingPage != null ) { form.setResponsePage( callingPage ); } RepeatingView rv = new RepeatingView( SingleItemFormContents ); for( Iterator views = display.getViews( ).iterator( ); views.hasNext( ); ) { IView view = (IView) views.next( ); rv.add( new FieldSetView( rv.newChildId( ), readonly, display, model, view ) ); } form.add( rv ); form.add( new SubmitLink( link1 ) { public void onSubmit( ) { display.getData( ).saveItem( model.getObject( ) ); // Call here works if( callingPage != null ) { form.setResponsePage( callingPage ); } } } ); add( form ); } } On Tue, Mar 25, 2008 at 11:32 AM, Johan Compagner [EMAIL PROTECTED] wrote: do you have some sample code?? what do you mean with setResponsePage outside of an onSubmit or click? outside of what? when is it called? On Tue, Mar 25, 2008 at 12:22 PM, Eric Rotick [EMAIL PROTECTED] wrote: I have a page with many buttons to do different things. I decided the best strategy was to setup the default page via a call to setReponsePage at the start of the page and then overrride this in the onSubmit method for each button. This appears not to work. However, if I set a value of the default page and override this value in the onSubmit method of each button and then only call the setResponsePage in the obSubmit method for the form then it works. I've also tried only making the call to setResponsePage in the onSubmit or onClick methods and this works. In summary, a call to setReponsePage outside of an onSubmit or onClick appears to have no effect. Is this correct and if so why? I can't find any docs to suggest not using this strategy.
Re: Unsure about setResponsePage behaviour
Thanks for the help, I'm getting there...slowly! Does this mean that I can't do something like new MyPage1( ).setResponsePage( new MyPage2( ) ); and then somewhere else new MyPage1( ).setResponsePage( new MyPage3( ) ); Instead I have to add a parameter to all pages that could have a variable response page and set that via the setReponsePage in an onSubmit call. As in new MyPage1( new MyPage2( ) ); and new MyPage1( new MyPage3( ) ); After all, the default response page is the page itself. All that is happening is resetting the default response page to something else. Be gentle ;- Eric. On Tue, Mar 25, 2008 at 12:24 PM, Johan Compagner [EMAIL PROTECTED] wrote: We really should remove all the RequestCycle methods from components if i read these kind of mails form.setResponsePage() doesn't mean that in the onSubmit that page is set as a response! That is something you should do yourself yes in the onSubmit() you dont have to do then form. just setResponsePage() is enough those methods are just all helper methods that are nothing more then relays to the RequestCycle You dont set state on the Object itself (like here form) johan On Tue, Mar 25, 2008 at 1:08 PM, Eric Rotick [EMAIL PROTECTED] wrote: I have simplified the class and it behaves the same. public class SingleItemForm extends Panel { public SingleItemForm( String id, final boolean readonly, final ISingleDisplay display, final IModel model, final Page callingPage ) { super( id ); add( new FeedbackPanel (feedback ) ); final Form form = new Form( SingleItemFormName ); // Call here has no effect if( callingPage != null ) { form.setResponsePage( callingPage ); } RepeatingView rv = new RepeatingView( SingleItemFormContents ); for( Iterator views = display.getViews( ).iterator( ); views.hasNext( ); ) { IView view = (IView) views.next( ); rv.add( new FieldSetView( rv.newChildId( ), readonly, display, model, view ) ); } form.add( rv ); form.add( new SubmitLink( link1 ) { public void onSubmit( ) { display.getData( ).saveItem( model.getObject( ) ); // Call here works if( callingPage != null ) { form.setResponsePage( callingPage ); } } } ); add( form ); } } On Tue, Mar 25, 2008 at 11:32 AM, Johan Compagner [EMAIL PROTECTED] wrote: do you have some sample code?? what do you mean with setResponsePage outside of an onSubmit or click? outside of what? when is it called? On Tue, Mar 25, 2008 at 12:22 PM, Eric Rotick [EMAIL PROTECTED] wrote: I have a page with many buttons to do different things. I decided the best strategy was to setup the default page via a call to setReponsePage at the start of the page and then overrride this in the onSubmit method for each button. This appears not to work. However, if I set a value of the default page and override this value in the onSubmit method of each button and then only call the setResponsePage in the obSubmit method for the form then it works. I've also tried only making the call to setResponsePage in the onSubmit or onClick methods and this works. In summary, a call to setReponsePage outside of an onSubmit or onClick appears to have no effect. Is this correct and if so why? I can't find any docs to suggest not using this strategy.
Re: Unsure about setResponsePage behaviour
Great, that explains it very well. Thanks for your help. Eric. On Tue, Mar 25, 2008 at 12:55 PM, Johan Compagner [EMAIL PROTECTED] wrote: no if you call on any component setResponsePage() then that page is set as the response at the time of the call. It is not internal state of that component that is then somehow picked up at some point A component/page doesn't have a default response page.. (the default response page is the page that is just rendered) So yes if you want to go back to a calling page then you have to give that to the constructor. johan On Tue, Mar 25, 2008 at 1:42 PM, Eric Rotick [EMAIL PROTECTED] wrote: Thanks for the help, I'm getting there...slowly! Does this mean that I can't do something like new MyPage1( ).setResponsePage( new MyPage2( ) ); and then somewhere else new MyPage1( ).setResponsePage( new MyPage3( ) ); Instead I have to add a parameter to all pages that could have a variable response page and set that via the setReponsePage in an onSubmit call. As in new MyPage1( new MyPage2( ) ); and new MyPage1( new MyPage3( ) ); After all, the default response page is the page itself. All that is happening is resetting the default response page to something else. Be gentle ;- Eric. On Tue, Mar 25, 2008 at 12:24 PM, Johan Compagner [EMAIL PROTECTED] wrote: We really should remove all the RequestCycle methods from components if i read these kind of mails form.setResponsePage() doesn't mean that in the onSubmit that page is set as a response! That is something you should do yourself yes in the onSubmit() you dont have to do then form. just setResponsePage() is enough those methods are just all helper methods that are nothing more then relays to the RequestCycle You dont set state on the Object itself (like here form) johan On Tue, Mar 25, 2008 at 1:08 PM, Eric Rotick [EMAIL PROTECTED] wrote: I have simplified the class and it behaves the same. public class SingleItemForm extends Panel { public SingleItemForm( String id, final boolean readonly, final ISingleDisplay display, final IModel model, final Page callingPage ) { super( id ); add( new FeedbackPanel (feedback ) ); final Form form = new Form( SingleItemFormName ); // Call here has no effect if( callingPage != null ) { form.setResponsePage( callingPage ); } RepeatingView rv = new RepeatingView( SingleItemFormContents ); for( Iterator views = display.getViews( ).iterator( ); views.hasNext( ); ) { IView view = (IView) views.next( ); rv.add( new FieldSetView( rv.newChildId( ), readonly, display, model, view ) ); } form.add( rv ); form.add( new SubmitLink( link1 ) { public void onSubmit( ) { display.getData( ).saveItem( model.getObject( ) ); // Call here works if( callingPage != null ) { form.setResponsePage( callingPage ); } } } ); add( form ); } } On Tue, Mar 25, 2008 at 11:32 AM, Johan Compagner [EMAIL PROTECTED] wrote: do you have some sample code?? what do you mean with setResponsePage outside of an onSubmit or click? outside of what? when is it called? On Tue, Mar 25, 2008 at 12:22 PM, Eric Rotick [EMAIL PROTECTED] wrote: I have a page with many buttons to do different things. I decided the best strategy was to setup the default page via a call to setReponsePage at the start of the page and then overrride this in the onSubmit method for each button. This appears not to work. However, if I set a value of the default page and override this value in the onSubmit method of each button and then only call the setResponsePage in the obSubmit method for the form then it works. I've also tried only making the call to setResponsePage in the onSubmit or onClick methods and this works. In summary, a call to setReponsePage outside of an onSubmit or onClick appears to have no effect. Is this correct and if so why? I can't find any docs to suggest not using this strategy.
Re: Unsure about setResponsePage behaviour
Good point. On Tue, Mar 25, 2008 at 2:01 PM, Maurice Marrink [EMAIL PROTECTED] wrote: On Tue, Mar 25, 2008 at 1:42 PM, Eric Rotick [EMAIL PROTECTED] wrote: Thanks for the help, I'm getting there...slowly! Does this mean that I can't do something like new MyPage1( ).setResponsePage( new MyPage2( ) ); and then somewhere else new MyPage1( ).setResponsePage( new MyPage3( ) ); Instead I have to add a parameter to all pages that could have a variable response page and set that via the setReponsePage in an onSubmit call. As in new MyPage1( new MyPage2( ) ); and new MyPage1( new MyPage3( ) ); You really should never pass a new Page to another like what you are doing here. Instead you should either pass the class of that page or if the page you are trying to pass on already has been created because you visited it previously then it would be ok to pass it to the constructor. So either do onsubmit() // or onclick { setResponsePage(new MyPage2(MyPage3.class); //or setResponsePage(new MyPage2(this.getPage()); //or setResponsePage(new MyPage2(pageThatWasPreviouslyConstructed)); //as in not constructed in this page } Maurice - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Adding dynamic form components to forms
I would like to be able to create a form where the number and type of form component is decided at run time. I've done the research and found various guides, e.g http://cwiki.apache.org/WICKET/forms-with-dynamic-elements.html but I've not managed to crack it yet. I've created some panels for the form components, one for a fieldset and one for the form. wicket:panel input type=text wicket:id=textValue /wicket:panel wicket:panel fieldset legend wicket:id=setNamesetName/legend table tr wicket:id=eachEntry td wicket:id=fieldNamefieldName/td td wicket:id=fieldValuefieldValue/td /tr /table /fieldset /wicket:panel wicket:panel form wicket:id=SingleItemFormName span wicket:id=SingleItemFormContents/ /form /wicket:panel When I use this final Form form = new Form( SingleItemFormName ); for( Iterator views = display.getViews( ).iterator( ); views.hasNext( ); ) { IView view = (IView) views.next( ); form.add( new FieldSetView( SingleItemFormContents, readonly, display, data, view ) ); } add( form ); it works but only if there is one view. The reason is clear so I thought this is the time to use a ListView. Note that I believe the code above shows that the markup and panels are all working OK but the second time I use the same id it barfs. If I use this final Form form = new Form( SingleItemFormName ); ListView contents = new ListView( SingleItemFormContents, display.getViews( ) ) { protected void populateItem( ListItem item ) { IView view = (IView) item.getModelObject( ); item.add( new FieldSetView( view.getName( ), readonly, display, data, view ) ); } }; contents.setReuseItems( true ); form.add( contents ); add( form ); I get the error that components failed to render. I've also tried final Form form = new Form( SingleItemFormName ); add( form ); ListView contents = new ListView( SingleItemFormContents, display.getViews( ) ) { protected void populateItem( ListItem item ) { IView view = (IView) item.getModelObject( ); item.add( new FieldSetView( view.getName( ), readonly, display, data, view ) ); } }; contents.setReuseItems( true ); add( contents ); form.add( contents ); and even final Form form = new Form( SingleItemFormName ); WebMarkupContainer wmc = new WebMarkupContainer( SingleItemFormContents ); for( Iterator views = display.getViews( ).iterator( ); views.hasNext( ); ) { IView view = (IView) views.next( ); wmc.add( new FieldSetView( view.getName( ), readonly, display, data, view ) ); } form.add( wmc ); but they all say that components failed to render. What am I missing? Thanks.