[Laszlo-user] Need to be able to override resource declarations in OpenLaszlo without warnings.

Boris Callens boris.callens.osv at fedex.com
Wed Aug 29 00:25:07 PDT 2007


I do support your suggestion.

But this issue rises another thought:
As I read it now, I do have to know the structure of the library before I  
can override something. Not?
This looks a lot like most AS2 code you see around where information  
hiding is something obscure and half-implemented.

Would a solution be to create getters and setters, or is there a better  
way to do this?

Just my 2cts
Boris

On Wed, 29 Aug 2007 00:35:31 +0200, Sarah Allen <sallen at laszlosystems.com>  
wrote:

>
>   I think this is an excellent proposal.  cc'ing laszlo-user to see if
> other folks developing in LZX have strong feelings about this ...
>
>
>
> On Tue, Aug 28, 2007 at  3:12 PM, Bret Simister wrote:
>
>
>
> Currently, in the OpenLaszlo platform, it was decided that declaring a
> resource twice within an LZX app
>
> causes a server warning. This was intended to help developers just  in
> case they accidentally overrode a
>
> resource that had already been  declared in another library.
>
>
>
> <!-- the following code produces a warning, but still compiles -->
>
> <canvas>
>
>      <resource name="logo" src="logo.gif" />
>
>      <resource name="logo" src="logo2.gif" />
>
>
>
>   <!-- view appears with logo2.gif -->
>
>      <view resource="logo" />
>
> </canvas>
>
>
>
>
> At this time, I would suggest that  the  platform remove these warnings
> and have
>
> the last resource declaration override all other previous declarations.
>
>
>
> Here is why...
>
>
>
> OpenLaszlo now has a CSS implementation. It gives developers an elegant
> method
>
> of skinning their applications. This works, currently,  by first
> declaring a resource
>
>
>
> <resource  name="someimage_rsc"  src="somepath/someimage.jpg" />
>
>
>
> and then referring to that resource in a CSS selector
>
>
>
> view[name="someview"] {
>
> resource: someimage_rsc;
>
> }
>
>
>
>
>
>
> If a developer builds a library ....
>
>
>
>    myCustomLibrary      ( folder )
>
>       library.lzx
>
>       myresources.lzx ( contains many resource definitions including
> 'lowerRightCorner_rsc' )
>
>       mystyles.css    ( contains many selectors including one that
> references 'lowerRightCorner_rsc' )
>
>       ...             ( other class and source image files )
>
>
>
> where  library.lzx  includes both   myresources.lzx and mystyles.css
>
>
>
> Then library can be used with a simple inclusion in the main app.
>
>
>
> <canvas>
>
>
>
> <include name="myCustomLibrary" />
>
>
>
> <!-- instance of a class from myCustomLibrary -->
>
> <mycustomclass />
>
>
>
> </canvas>
>
>
>
>
>
> Let's assume that " mycustomclass " contains a number of resources, and
> that you ( as a developer )
>
> only want to change one of those resources . The simplest method to
> accomplish this would be ...
>
>
>
> <canvas>
>
>
>
> <include name="myCustomLibrary" />
>
>
>
> <!-- override resource definition "lowerRightCorner_rsc" defined earlier
> in myresouces.lzx -->
>
> <resource name="lowerRightCorner"
> src="my_new_path/my_lower_right_corner.jpg" />
>
>
>
>
> <!-- instance of mycustomclass that will now display
>
>           the new resource based on the unchanged css selector -->
>
> <mycustomclass />
>
>
>
> </canvas>
>
>
>
> Currently, this code would cause a compiler warning. To avoid these
> warnings ( without changing OpenLaszlo ) the  resouces.lzx file(s) and
> possibly the  library .lzx would have to be edited.
>
>
>
> If instead, we allow for resource overriding, then ...
>
>
>
> 1) the original CSS and  resource files will remain unchanged
>
> 2) The old resource for " lowerRightCorner"  would NOT be included in
> the app
>
> 3) There  would be clean separation between external libraries and the
> skinning of theses libraries  included in an application.
>
>
>
>
>
>
>
>
>



-- 
Boris Callens
FedEx


More information about the Laszlo-user mailing list