RE: TEXTAREA element and Barracuda

Jacob Kjome <[email protected]>
Newsgroups gmane.comp.java.enhydra.barracuda.general
Message-ID <[email protected]>
Hi Kirk,

Sounds like a nice way to do things.  Want to create a small contrib 
project demoing this approach?  I'd be happy to commit it for you.  Just 
model it after the existing contrib projects by Diez and Stefan.

 >The only drawback is that I do hardcode things like javascript and css 
styles.

I wonder how much hard coding your really need to have?  Rather than 
defining inline css styles, you can do it in one or more linked 
stylesheets.  As for the javascript, you now have the capability of using a 
BAction component and specifying javascript functions that should be run on 
the client side before a form is actually submitted.  For instance....

BAction bcomp = new BAction();
bcomp.addScriptFunction("checkMyForm");

What will happen on the client side is that the javascript function 
checkMyForm(objForm) will be called before any form submission 
happens.  This assumes that checkMyForm() takes a form object as the first 
argument and returns a boolean.  This allows you to be able to return false 
early, effectively short-circuiting the form submit in the case that the 
form hasn't validated properly.  You can add as many script functions as 
you want.

Do those suggestions get rid of the need to hard code javascript and css?


Jake

At 07:00 PM 5/2/2003 +0200, you wrote:
>Hi Jake,
>
>Yes...of course...your're correct.
>I did think of this.
>But there was a reason I implemented my TextArea's this way(and all other 
>controls for that matter).
>
>
>I reuse a single XMLC page... and render the page differently deppending 
>on the user's rights.
>These pages are used strictly for data entry..
>
>E.g.
>A user needs to enter company information...
>let's say ...Company Name...
>
><span class="Dir::Get_Data.ExampleModel.p_companyName">[THE COMPANY]</span>
>
>On the 'New' Screen... I'd might have  a simple textBox...
>When the user edit's the record on the 'Edit' screen.. I might display a 
>list(drop down) of registered Companies...
>(terrible example)...
>
>So.
>Instead of having 2 or 3 (New/Edit/View) Tags for a single field on the 
>same page..
>I have a single tag..
>
>I have a interface that my all my dataAware models implement with mainly 3 
>methods.
>
>public interface HandlePresentation {
>   public Object handleDefault(ViewContext vc,String key);
>   public Object handleFind(ViewContext vc,String key);
>   public Object handleNew(ViewContext vc,String key);
>   public Object handleEdit(ViewContext vc,String key, BusinessRule 
> businessRule);
>   public Object handleView(ViewContext vc,String key, BusinessRule 
> businessRule);
>
>   .
>   .More methods follow
>   .
>}
>
>Depending on the 'event'.... I call the relevant method... 
>(handleNew/handleEdit), etc
>
>This works great... and really cuts down on the number of tags I need to 
>define.
>The only drawback is that I do hardcode things like javascript and css styles.
>That's about it.
>
>Regards
>KD
>
>-----Original Message-----
>From: Jacob Kjome [mailto:[email protected]]
>Sent: 02 May 2003 06:19
>To: [email protected]
>Subject: RE: [Barracuda] TEXTAREA element and Barracuda
>
>
>Hi Kirk,
>
>Why not have a <textarea> element with a BTemplate directive and return 
>null if the condition says that it shouldn't be displayed?  That should 
>remove the element from the output, if I'm not mistaken.
>
>Jake
>
>At 03:55 PM 5/2/2003 +0200, you wrote:
>>Hi,
>>
>>In the example.. I needed to conditionally create the textArea within the
>>HTML page.
>>It depends on the users rights..
>>E.g.
>>
>>A user with create or edit rights... would be presented with the textArea
>>for updating..
>>A user with only 'View' rights would just see the 'text' without the
>>textArea being rendered for updating.
>>
>>Here's the HTML snippet..
>>
>><span class="Dir::Get_Data.ExampleModel.Note">[TEXT AREA HERE]</span>
>>
>>Regards
>>KD
>>
>>-----Original Message-----
>>From: Diez B. Roggisch [mailto:[email protected]]
>>Sent: 02 May 2003 03:47
>>To: [email protected]
>>Subject: Re: [Barracuda] TEXTAREA element and Barracuda
>>
>>
>>Hi,
>>
>>Kirk Daries wrote:
>> > } else if (key.equals("Note")) {
>> >       Document doc = vc.getTemplateNode().getOwnerDocument();
>> >       Node targetNode = doc.createElement("TEXTAREA");
>> >       View view = new DefaultView(targetNode);
>> >       BComponent b = new BComponent();
>> >       b.setView(view);
>> >       b.setName("p_note");
>> >       b.setAttr("class","TextBox");
>> >       b.setAttr("id","M,NOTE");
>> >       b.setAttr("cols","30");
>> >       b.setAttr("rows","3");
>> >       return b;
>>
>>Thats really complicated. In my TextAreaFormElement from the
>>repopulation-package I simply return a BText (as Christian pointed out
>>before). Then all this rows/cols/whatever stuff can be put in the html.
>>
>><textarea class="Dir::Get_Data.ExampleModel.TEXTAREA" rows="3"
>>cols="30"></textarea>
>>
>>
>>Diez
>>
>>
>>_______________________________________________
>>Barracuda mailing list
>>[email protected]
>>http://barracudamvc.org/lists/listinfo/barracuda
>>_______________________________________________
>>Barracuda mailing list
>>[email protected]
>>http://barracudamvc.org/lists/listinfo/barracuda
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.