• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Problem with webobject attributes in WOBuilder
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with webobject attributes in WOBuilder


  • Subject: Re: Problem with webobject attributes in WOBuilder
  • From: Lachlan Deck <email@hidden>
  • Date: Fri, 23 Jun 2006 08:04:21 +1000

Hi there,

On 15/06/2006, at 7:56 AM, David Masters wrote:

On 14 Jun 2006, at 12:54, John Stewart wrote:

If I create a ul wrapper "styleContainer" as below, I'd like to
include the "open" or "closed" styles, as well as a common "clear"
style.

The output would be of the form:

<!-- isOpen = true: -->
 <ul class="clear open">
   <li>...</li>
 </ul>


<!-- isOpen = false: --> <ul class="clear closed"> <li>...</li> </ul>

One approach (as I think David LeBer mentioned) is to avoid the use of conditionals in the WOComponent with the use of WOGenericContainers, and a method in the .java file to return the class name as a String. For example, create a generic container with the element name of 'ul' and bind its (css) class to the method.


In .html:

	<webobject name="Generic1">
		...list repetition goes here...
	</webobject>

In .wod:

	Generic1: WOGenericContainer
	{
		elementName = "ul";
		class = classForList;
	}

Actually, to achieve what you want (in having your components' java void of any view logic) create your own GenericContainer (etc for other reusable components) that has at least the following in its java implementation:


--- LDGenericContainer.wo/LDGenericContainer.html ---
<webobject name="Container"><webobject name="String"></ webobject><webobject name="Content"></webobject></webobject>


--- LDGenericContainer.wo/LDGenericContainer.wod ---
Container: WOGenericContainer {
	elementName = ^elementName;
	invokeAction = ^invokeAction;
	formValue = ^formValue;
	elementID = ^elementID;
	omitTags = ^omitTags;
	otherTagString = otherTagString;
}

Content: WOComponentContent {}

String: WOString {
    value = ^string;
}

--- LDGenericContainer.java ---
public class LDGenericContainer extends WOComponent {

	public LDGenericContainer( WOContext context ) {
		super( context );
	}

	protected void append( Object value, StringBuffer buff ) {
		if ( value != null ) {
			if ( buff.length() > 0 )
				buff.append( " " );
			buff.append( value );
		}
	}

	public String classString() {
		StringBuffer buff;

		buff = new StringBuffer();
		for ( int i = 1; true; i++ ) {
			if ( ! hasBinding( "class" + i ) ) {
				break;
			}
			buff.append( valueForBinding( "class" + i ) );
		}
		if ( buff.length() > 0 ) {
			buff.insert( 0 , "class=\"" );
			buff.append( "\"" );
		}
		return buff.toString();
	}

	<...>

	public String otherTagString() {
		StringBuffer result;
		Object value;

		result = new StringBuffer();
		if ( hasBinding( "otherTagString" ) ) {
			append( valueForBinding( "otherTagString" ), result );
		}
		append( classString(), result );

		return result.toString();
	}

}

Example use:
SomeList: LDGenericContainer {
	<...>
	class1 = "clear";
	class2 = "open";
	...
	classN = "blah";
}

with regards,
--

Lachlan Deck


_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: Problem with webobject attributes in WOBuilder
      • From: "John Stewart" <email@hidden>
References: 
 >Problem with webobject attributes in WOBuilder (From: "John Stewart" <email@hidden>)
 >Re: Problem with webobject attributes in WOBuilder (From: "John Stewart" <email@hidden>)
 >Re: Problem with webobject attributes in WOBuilder (From: David Masters <email@hidden>)

  • Prev by Date: [SOLVED] Problems creating a framework with model inside
  • Next by Date: Re: Problem with webobject attributes in WOBuilder
  • Previous by thread: Re: Problem with webobject attributes in WOBuilder
  • Next by thread: Re: Problem with webobject attributes in WOBuilder
  • Index(es):
    • Date
    • Thread