text:
Classical Mechanics/Lagrange Theory

Up

This section contains several theoretical developments of the Lagrangian formalism that are not directly necessary for solving problems. However, these considerations help understand the theory more deeply and answer certain important questions.

Why does the extremum of a functional determine motion?
In the Lagrangian formulation of mechanics, the trajectory $$\vec q(t)$$ is determined from the condition that the action functional $$S[\vec q(t)]$$ should have an extremum. (It is not always the case that the trajectory is the minimum of the action; in some cases it might be merely an extremum, i.e. a point where the functional derivative $$\delta S/\delta \vec q(t)$$ vanishes.) This condition is known as the action principle. By now, you should be familiar with the mathematical procedures used to derive the equations of motion from the action principle.

So, at this point, you should be well used to the fact that the correct equations of motion for each mechanical system indeed follow from the action principle, if the Lagrangian is chosen appropriately. However, it might still feel like a mystery to you that Newton's laws are equivalent to the condition for the extremum of some functional. You might be asking yourself: why is this possible at all?

Here is one explanation that may help. Let us consider a simple mechanical system: a point mass $$m$$ moving in one dimension, with coordinate $$x(t)$$, in a potential $$U(x)$$. (The same considerations can be easily generalized to the case of more than one dimensions and more than one coordinate.) Suppose that $$x_0(t)$$ is the correct trajectory according to Newton's law, $$m\ddot x_0(t) = - \left .\frac{dU}{dx}\right| _{x=x_0(t)}.$$ How can we use a functional $$S[x]$$ to express the condition that the trajectory $$x(t)$$ is the correct one? One way is to demand that the deviation of $$x(t)$$ from $$x_0(t)$$ is everywhere zero. This can be expressed using the functional $$S_1[x]= \int _{t_1}^{t_2} [x(t)-x_0(t)]^2 dt.$$ It is clear that the functional $$S_1[x]$$ has the minimum value (obviously the minimum is 0) if and only if $$x(t)=x_0(t)$$ for all $$t$$. This is an example of how to use a functional to express some condition on functions: the functional $$S_1[x]$$ measures the deviation of $$x(t)$$ from $$x_0(t)$$ all along the way. The smallest possible deviation is no deviation at all; thus, the minimum of the functional $$S_1[x(t)]$$ is at the trajectory $$x(t)$$ that does not deviate at all from $$x_0(t)$$.

Another similar way to specify the trajectory is to use the functional $$S_2[x]= \int _{t_1}^{t_2} [\dot x(t)-\dot x_0(t)]^2 dt.$$ This functional, together with the boundary conditions  $$x(t_1)=x_0(t_1),x(t_2)=x_0(t_2)$$, has the minimum value if and only if $$x(t)=x_0(t)$$ for all $$t$$.

Admittedly, the functionals $$S_1[x], S_2(x)$$ do not help us to formulate the laws of mechanics, because they already contain the correct trajectory $$x_0(t)$$ explicitly. We shall now construct another functional, $$S_3[x]$$, starting from $$S_2[x]$$ and trying to eliminate the explicit dependence on $$x_0(t)$$.

Let us rewrite $$S_2[x]$$ as $$S_2[x]= \int _{t_1}^{t_2} [\dot x^2-2\dot x\dot x_0+\dot x_0^2] dt.$$ The third term, $$\dot x_0^2$$, is a fixed function and does not vary when we vary $$x(t)$$. Therefore we may omit that term from $$S_2$$. Furthermore, we would like to have $$\ddot x_0$$ rather than $$\dot x_0$$, since we could then use Newton's law for the correct trajectory. So let us integrate the second term by parts: $$-2\int _{t_1}^{t_2} \dot x\dot x_0 dt=-2\left. x\dot x_0 \right|^{t_2}_{t_1}+\int _{t_1}^{t_2} 2x\ddot x_0 dt.$$ The boundary term $$\left. x\dot x_0 \right|^{t_2}_{t_1}$$ does not vary with $$x(t)$$ since the boundary values of $$x(t)$$ are fixed. Therefore we may omit that term. Finally, we use Newton's law to replace $$\ddot x_0$$ by $$-m^{-1}U'(x_0)$$: $$\int _{t_1}^{t_2} 2x\ddot x_0 dt=-\int_{t_1}^{t_2} 2m^{-1}xU'(x_0).$$ If we now assume that the trajectory $$x(t)$$ deviates very little from the correct trajectory $$x_0(t)$$, then we may approximately write $$xU'(x_0)=(x-x_0)U'(x_0)+x_0 U'(x_0)=U(x)-U(x_0)+O[(x-x_0)^2]+x_0 U'(x_0).$$ The term quadratic in $$(x-x_0)$$ can be omitted under the above assumption. The terms $$U(x_0)$$ and $$x_0 U'(x_0)$$ can be omitted since they are independent of $$x(t)$$. Thus we find that the functional $$S_2$$ is equivalent, up to inessential terms that do not vary with $$x(t)$$, to the following functional: $$S_3[x]= \int _{t_1}^{t_2} [\dot x^2 -2m^{-1}U(x)] dt.$$ It is clear that $$S_3$$ is equivalent to the usual Lagrangian up to the coefficient $$m/2$$.

In this way, we obtained a functional $$S_3[x]$$ which has a minimum when $$x(t)$$ is very close to $$x_0(t)$$; i.e. it is a local minimum. The new functional does not depend explicitly on $$x_0(t)$$, just as we wanted. The price to pay is that this functional works only for small deviations from the correct trajectory. Indeed, the functional $$S_3$$ may have other minima or maxima which the original functional $$S_2$$ does not have. The only real justification for the correctness of $$S_3$$ is that the equations of motion coincide with Newton's law.

Why can we use arbitrary coordinates to write the Lagrangian?
In simple cases, the Lagrangian is equal to the difference of the kinetic and the potential energy terms. However, one needs to select some coordinates to describe these terms. Then it is completely unimportant which variables are chosen as coordinates; these variables could be lengths, angles, or any functions of lengths and angles (but not velocities!). In other words, one can use any coordinate systems or even just parts of some coordinate systems, as long as the possible positions of every mass point is adequately described by the coordinates and the appropriate constraints. For this reason, the coordinates entering the Lagrangian are called generalized coordinates. Usually, one chooses generalized coordinates for convenience, to minimize the required computational work, or to decrease the number of necessary constraints.

However, you may be asking yourself: why is it that one is allowed to use arbitrary coordinates in the Lagrangian formalism? Certainly, as we know, Newton's laws are not the same in different coordinates: for instance, the mass times the acceleration is equal to the force only if the acceleration is computed as $$\ddot \vec x(t)$$, where $$\vec x(t)$$ is the vector of Cartesian coordinates $$(x,y,z)$$. This formula will be incorrect if the vector $$\vec x=(x_1,x_2,x_3)$$ were to consist of, say, the radius $$r=\sqrt{x^2+y^2+z^2}$$, the azimuthal angle $$\phi$$ in the $$(x,y)$$ plane, and the coordinate $$z$$. However, the Lagrangian formalism will work just fine if we express the kinetic and the potential energy through the variables $$(x_1,x_2,x_3)=(r,\phi,z)$$. The equations of motion will be given by the Euler-Lagrange equation, $$\frac{d}{dt}\frac{\partial L}{\partial \dot \vec x}=\frac{\partial L}{\partial \vec x},$$ as before. One says that the Lagrangian formalism is covariant with respect to coordinate transformations.

The reason for this can be explained in two ways: either more formally, by showing that the Euler-Lagrange equations remain the same under an arbitrary change of coordinates; or more visually, by approaching the situation from the geometric point of view.

Formal derivation
For simplicity, we shall only consider a one-dimensional problem with a Lagrangian $$L(q,\dot q,t)$$, where $$q(t)$$ is a generalized coordinate. The same consideration is very easily generalized to the case of multiple coordinates.

Suppose that a new coordinate $$x(t)$$ is chosen instead of $$q(t)$$. The new coordinate can be a function of the old coordinate. Let us consider an even more general case where the change of coordinates depends on time (i.e. we may choose slightly different coordinates at different times). Then the new coordinate is related to the old one by a formula such as $$q(t)=F(x(t),t),$$ where $$F(x,t)$$ is a known function.

Now we need to express the old Lagrangian $$L(q,\dot q,t)$$ through the new variable $$x$$ and its derivative $$\dot x$$. We have $$\dot q = F_{,t}+F_{,x} \dot x,$$ where we denote partial derivatives by subscripts with commas, e.g. $$\partial f(a,b,c)/\partial a \equiv f_{,a}$$. This is a condensed notation frequently used in physics.

The Lagrangian expressed through the new variable $$x$$ is therefore $$L(q,\dot q,t)=\tilde L(x,\dot x,t)=L(F(x,t), F_{,t}+F_{,x} \dot x, t).$$ The new variable $$x$$ is a good variable if it is a nontrivial function of the old one, i.e. if $$F_{,x}\neq 0$$. Then the new Lagrangian will be a nontrivial function that depends on $$\dot x$$ as well as on $$x$$. So we shall assume that $$F_{,x}\neq 0$$ at least within some interval of $$x$$.

Now let us compare the equations of motion (EOM) that we would derive in the old coordinates and in the new coordinates.

The old EOM can be written as $$\frac{d}{dt}L_{,\dot q}=L_{,q}.$$ The new EOM is $$\frac{d}{dt}\tilde L_{,\dot x}=\tilde L_{,x}.$$ Let us express this equation through $$L$$ instead of $$\tilde L$$: $$\tilde L_{,x}=L_{,q} F_{,x}+L_{,\dot q}(F_{,tx}+F_{,xx}\dot x),$$

$$\tilde L_{,\dot x}=L_{,\dot q} F_{,x},$$

$$\frac{d}{dt}\tilde L_{,\dot x}= F_{,x}\frac{d}{dt}L_{,\dot q}+L_{,\dot q}\frac{d}{dt} F_{,x}.$$ Therefore, the new EOM is $$F_{,x}\frac{d}{dt}L_{,\dot q}+L_{,\dot q}\frac{d}{dt} F_{,x} = L_{,q} F_{,x}+L_{,\dot q}(F_{,tx}+F_{,xx}\dot x).$$ Simplifying this expression, we find $$F_{,x} \frac{d}{dt}L_{,\dot q} = F_{,x} L_{,q}.$$

We find that the new EOM is indeed equivalent to the old one, under the assumption that $$F_{,x}\neq 0$$.

Geometric picture
The computation presented above is straightforward and explicit, but may leave you wondering why it works. Here is a more visual explanation.

The Euler-Lagrange equations express the condition that the functional $$S[q]$$ has an extremum at the trajectory $$q(t)$$. Let us imagine a space of all trajectories, i.e. some huge space where each "point" represents one entire trajectory $$q(t)$$. The functional $$S[q]$$ has an extremum at some "point" $$q_0$$ which is the actual trajectory of the mechanical system. When we change coordinates, $$q \to x$$, we merely change our description of this space of trajectories. We cannot change the fact that the functional $$S$$ has an extremum somewhere, at some "point" $$q_0$$. We may only change our description of this "point". Therefore, after a change of variables the new functional $$\tilde S[x]=S[q]$$ will again have an extremum at some "point" $$x_0$$, and this "point" $$x_0$$ will have to correspond to the "point" $$q_0$$ after the change of variables. The existence of the extremum is a geometric characteristic of the shape of the functional $$S$$; that's why it is independent of the way we choose to describe it with coordinates.

Let us consider a simple example where we use functions instead of functionals. The function $$f(q)=(q-1)^2$$ has a minimum at $$q=1$$. We may change coordinates and use $$x$$ instead of $$q$$, where e.g. $$q=F(x)\equiv 2\sin x$$. This is a well-defined change of variables on the interval $$x \in (-\pi/2, \pi/2)$$, where $$F_{,x}\neq 0$$. In the new coordinates, the function $$f(q)$$ looks like $$\tilde f(x)=(2\sin x-1)^2$$. This function has a minimum at $$x=\pi/6$$ where $$2\sin x=1$$. But geometrically speaking, this is exactly the same function as before, except viewed in different coordinates. Therefore, it is no surprise that the minimum $$x=\pi/6$$ is the old minimum $$q=1$$ after the change of coordinates.

This equivalence can be seen more formally. The condition for the minimum of the function $$\tilde f(x)$$ is $$\frac{d}{dx} \tilde f(x) =0=\frac{df(q)}{dq} \frac{dF}{dx} .$$ This condition is equivalent to the condition for the minimum of the function $$f(q)$$, namely $$f_{,q}=0$$, as long as $$F_{,x}\neq 0$$. This is why the position of the minimum in the old coordinates, $$q=1$$, exactly corresponds to the position of the minimum in the new coordinates, $$x=\pi/6$$.

Similarly, when we consider functionals, we may write the condition for the minimum of $$\tilde S[x]=S[F(q)]$$ in new coordinates as $$\frac{\delta \tilde S}{\delta x(t)} = 0= \frac {\delta S}{\delta q(t)}\frac{dF}{dx}.$$ It is clear that the condition for the minimum remains the same under the change of variables, as long as the new variables are well-defined, i.e. $$F_{,x}\neq 0$$.

Is the Lagrangian unique?
Another important question is whether there is only one Lagrangian that yields the correct equations of motion for a given system. The answer is that there are infinitely many different Lagrangians that can be used for any given system.

First of all, one may always multiply the Lagrangian by a constant $$\alpha$$ and also add an arbitrary fixed function of time, $$F(t)$$, to the Lagrangian. The modified Lagrangian is then $$\tilde L(q,\dot q,t)= \alpha L(q,\dot q,t)+F(t)$$. The term $$F(t)$$ is "fixed" in the sense that it does not depend on $$q(t)$$. Then we can integrate this term explicitly and express the modified action as $$\tilde S[q]=\alpha S[q]+\int _{t_1}^{t_2}F(t)dt.$$ The last term above is simply a number. Clearly, this modification of the action is irrelevant: if $$q(t)$$ is an extremum of $$S[q]$$, then it is also an extremum of $$\tilde S[q]$$. Adding a constant to a function does not change the position of the extrema.

More generally, we may add an arbitrary total time derivative to the Lagrangian: $$\tilde L=L+\frac{d}{dt}F(q,t).$$ The resulting modification of the action is $$\tilde S[q]=S[q]+\int _{t_1}^{t_2}\frac{d}{dt}F(q,t)dt=S[q]+F(q_2,t_2)-F(q_1,t_1),$$ where $$q_1,q_2$$ are the boundary values of $$q(t)$$. Since these values are fixed and do not vary when we vary $$q(t)$$, the extra term in the action is again a constant. Therefore, this modification of the action does not change the equations of motion. One says that two Lagrangians differing by a total derivative are equivalent.

One may even allow functions $$F$$ that depend on derivatives of $$q(t)$$ as well as on $$q(t)$$. However, in this case one would need to keep fixed also the values of the corresponding derivatives of $$q(t)$$ at the boundary points $$t_1,t_2$$.

So, as we see, the Lagrangian for a given physical system is not unique. The recipe "kinetic energy minus potential energy" is merely a simple rule that yields a good Lagrangian.

The variety of equivalent Lagrangians is not limited to those that differ by a total derivative or by a constant coefficient. For example, the Lagrangians $$L(q,\dot q)=q^2\dot q^4, \quad \tilde L(q,\dot q)=q^3 \dot q^6,$$ lead to the same equation of motion, $$ [\dot q^2+2q\ddot q]q\dot q^2=0,$$ even though one obviously cannot find a function $$F(q,t)$$ and a constant $$\alpha$$ such that $$L = \alpha L + dF/dt$$. (Such a function would produce at most an extra $$F_{,q}\dot q$$ term in the Lagrangian, but not terms that are nonlinear in derivatives.)

title: Classical Mechanics/Lagrange Theory


text: User:Dessydes~enwikibooks/Video game design

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
User:Halibutt

Please refer to my page on English wiki. Thank you.

title: User:Halibutt


text:
User:KristianMolhave/notes

Handbook of Nanotechnology

=References=
 * PMID 12829145
 * DOI in a similar way?

=Math= Help:Formula

=boxes= This box is just a test for a template under construction for the nanowiki:

=tables=

=intro to EM=

title: User:KristianMolhave/notes


text:
User:Jeremyfoland

Hi Jeremyfoland - You might consider adding the outline to the chapter page instead of the main page as you are building the chapter. Just a suggestion to unclutter the front page (which is quickly growing!) G.

Hi again - this is the place where we can post messages directly between different people developing the book. I would suggest moving the material you posted into your chapter, so that your group can keep greater control over it. Gerardo.ok 18:32, 28 May 2006 (UTC)

title: User:Jeremyfoland


text:
WebObjects/Alternative Technologies/Ruby on Rails

Myth: WebObjects is hard to use with Ajax.
Reality: WebObjects is relatively easy to use with Ajax if you can get documentations, it's just that there is only one known library for Ajax-WO support, and its not well documented. Even then the library only goes so far in that it just provides new components to wrap a few script.aculo.us tags.

Additionally, the WO documentation has always pushed people erroneously towards component actions and away from direct actions.

''[Which is to say, if you avoid much of the power of WO, and don't use component actions, ajax will be easier. If you do use component actions - and I have yet to work on a project that doesn't - then ajax use seems like it will blow your page cache, as described below. So it really is easy to use AJAX in WO. Really easy. It's just that it doesn't work.]''

''[mschrag: While I agree with the above commenter that component actions provide a huge amount of power in WO, it is NOT true that Ajax and component actions are incompatible. Project Wonder's Ajax components directly addresses the use of component actions with Ajax in a way that does NOT blow the page cache. While it is true that the implementation of these capabilities inside of Wonder was non-trivial, it demonstrates that it is, in fact, possible, and if you use the PW components along with ERXSession, you will get this capability for free.]''

Myth: You can't assign the name or id value of tags in WebObjects.
I'm mentioning this one explicitly, because I had someone ask me about this recently, because they were trying to assign a WYSIWYG JavaScript editor to a text area.

Reality: Actually, what really happens is that if you DON'T have a name=value or id=value line for your TextArea in WebObjects, it will generate a unique one for you. But you're more than welcome to specify one in your .wod file, and WO will use that. It's then up to _you_ to make sure its unique, so that you don't have multiple text area tags with the same name. In other words if you only have one textarea you wish to attach a Javascript WYSIWYG editor to, just add:

textarea: WOText {   id='wysiwyg'; name='wysiwyg'; value=textValue; }

in your .wod file and you can use id with your Javascript just fine.

Myth: WebObjects generates HTML
Reality: Just because the components of your .wo file are .html and .wod doesn't mean WebObjects can only generate HTML. WebObjects is really at heart, a very, very, very, complicated printf. The result of a component can be HTML, XML, JavaScript, or even binary data. You can actually put whatever you want in the .HTML and treat WebObjects like a giant merge engine. For instance, you could generate PDF files using WebObjects; they're just text, and you could substitute text into the middle of the PDF boilerplate pretty easily.

''[I left this assumption here but I considere removing it since nobody care about the fact that WO is able to generate a bastard pdf file. People care about Javascript generation code like GWT is able to do and it's true that WO is unable to do this]''

Research
So the first thing I did was that I'd heard that Rails was cool and made Ajax easy. I'd heard that before, but that was when the version number was 0.13... So I went out and bought the Rails books and you know what I found?

It's not that Rails rocks with Ajax, its that the Prototype Javascript library rocks. The documentation makes a big deal about doing Ajax with one line of code.

The reality is that all Rails is doing is writing one line of JavaScript. From the Ajaxy "rating" code I've been adding to my app, look at the following:

Ok, so lets break it down. The way Ajax.Updater works from the Prototype library is you give it the id of a DOM object and a URL, and it replaces the DOM object with that id with the contents of the URL. Usually, you specify the area to update with a div tag which I've shown for completeness. For ratings I would need 1 div tag to enclose all 5 rating stars: . I would also use a WOGenericContainer to generate the div tag with the right id rather than using the id='' line, but I wanted it to be obvious it was div tag.

So the Ajaxy part is the  tag, not the div tag.

Here I have a manually built  tag with an onclick bit of javascript. That makes a single call out to the Prototype library, which has this cool call:

new Ajax.Updater( elementid, url, options)

It does something very simple: It pulls the HTML from the specified URL, and replaces the element with the specified id with the downloaded HTML.

The two WebObjects tags specify the element ID and the link, they're just a WOString and a WOActionURL:

postingID: WOString { currentPosting.primaryKeyString; } ratePosting: WOActionURL { see discussion }

Now in my case, I'm a direct action snob. So my WOActionURL would look like the following:

ratePosting :WOActionURL {   directActionName="PostingRater"; ?pkey=currentPosting.primaryKey; ?rating=cRating; ?wosid=NO; }

This produces a result similar to Rails, because in rails you have to define an action for each class of link. In my case I tie directactions to pages/components, so my "PostingRater" page would return component-level HTML (minus any HEAD/BODY tags) that matched the existing  definition. Since we're using WebObjects, that turns out to be trivially easy if we build the enclosing  tag with a component PostingRater can just look like:

Using component actions, it could be even simpler:

ratePosting: WOActionURL { action=ratePosting;}

Because WebObjects, unlike Rails can have stateful components, the RatingDiv component could actually have all the logic and return self as the result of the action:

public WOReponse ratePosting {   currentPosting.ratePosting(currentRating); return self; // since this is called from JavaScript // return just myself, not self.page // this will tell WO to render only // this as a result. }

That is, the link for the javascript would go into the RatingDiv component with everything already setup: the current posting, the current rating. Returning self then causes the div to regenerate.

'''However, there's a gotcha there, because component actions called from javascript count towards your backtracking count. Since someone might be going down through the page clicking rating after rating, that could be a problem. If your max backtracking count was 10, and you had 20 postings on a page, they wouldn't be able to rate the 11th page.'''

So where Rails has one line, I have two WOTags, but those could (and should) be easily combined by creating a WODynamicElement to generate the link directly. In essence, it would be pretty easy to create a "RemoteLink" WODynamicElement that did everything the Rails "link_to_remote" call did, namely take an id to update along with all the options WOActionURL takes.

But additionally the WebObjects solution is superior in a number of ways to the Rails solution. Rails has support for both "partial pages" and "components" but the reality is that components are pretty heavyweight/slow and partials don't quite do what you think. So the WebObjects solution, by wrapping both the logic and state into a component ends up being more DRY (Don't Repeat Yourself) and better encapsulated than the typical Rails solution. In the page where you want the Ajax bit, you specify the component, and you put the ajax handling logic in the component itself.

I have yet to see anything in the Rails Ajax support that couldn't be just as easily done in WO via a combination of WOComponents and WODynamicElements. Pretty much everything in the Rail "Ajax support" are one-liners in Prototype. In fact, because pages/components can have state, its probably _easier_ to do it in WO than in other systems. Also, I think you could build a set of WOComponents that provided _superior_ Ajax support than Rails. It's just that no one has written the supporting WODynamicElements or WOComponents.

Now looking at the dojo Hello World example Ahmet, I have to say, that there's nothing in WebObjects that precludes doing anything in this. 90% of this tutorial is JavaScript that isn't specific to any particular technology. The parts that are specific to PHP/ASP/ColdFusion are defining a new page just like you'd have to do in WebObjects. Just use a WOActionURL where it says url: in the Javascript and you're done.

I also think, that from this example, dojo is a bit weak as a Javascript toolkit. You'll spend a lot of time wiring stuff up in Javascript with Dojo compared to Prototype. Or contrast dojo with the Yahoo UI library:

http://developer.yahoo.com/yui/

The whole "Dialog" thing in yui is cool:

http://developer.yahoo.com/yui/container/dialog/index.html

And would lend itself quite readily to the model WO has of building pages out of pieces.

Then again, dojo is only at version 0.3. The WYSIWYG editor is nice, but I really don't want to have to define my dialog boxes in yet another tag language. HTML is good enough for me.

So exactly what problems are you having with dojo/wo? Consider that the problem may be dojo, not WO in particular. You could easily create a WODynamicElement for every new dojo tag, collect them in components, and have something much easier to use than straight dojo.


text:
A-level English/Wise Children/Understanding the complex family tree

Nora and Dora Chance are the illegitimate daughters of Melchior Hazard officially known as the daughters of Peregrine (Perry) Hazard. Their mother is apparently Pretty Kitty, who died in childbirth; there are implications that Grandma Chance is their actual mother, but it isn't said outright that she is. Dora says 'Nature over nurture, ducky' when talking about their similarities with Grandma Chance.

Melchior and Perry Hazard are the sons of Estella and Ranulph Hazard, although questions are raised as to whether Ranulph is their real father, and whether Melchior and Perry are in fact the sons of Cassius Booth ('Horatio').

Saskia and Imogen Hazard are the daughters of Melchior's first wife, Lady Atlanta Hazard, née Lynde (aka Lady A or Wheelchair). They are legally Melchior's daughters but biologically the result of an affair Lady A had with Perry.

Tristram and Gareth Hazard are the offspring of Melchior and his third wife, Lady Margerine. Although Dora even suggests that these children may not be Melchiors. Gareth had an affair with an unknown woman and produced the two twins, one boy and one girl (described as a first in the family). Nora and Dora adopt the twins at the end of the novel.

Tiffany is Nora and Dora's goddaughter. Her mother is Brenda, her grandmother is Mavis, and her greatgrandmother is 'Our Cyn'. Grandma Chance took Our Cyn in when she was 14.

 * Note how the paternity of three sets of twins (Melchior and Peregine, Tristram and Gareth, and Saskia and Imogen) is questioned. In Contrast, Dora refutes suggestions over who is her mother and she also knows who is the mother of Tristram and Gareth's baby.
 * The line "a father is a hypothesis but a mother is a fact" sums up the above paragraph.


text:
WebObjects/Project WONDER/Frameworks/ERExtensions

WOF Extensions

 * ERXBasicBrowser
 * ERXBrowser
 * ERXBrowserFactory
 * ERXConfigurationManager
 * ERXConstant
 * ERXDirectAction
 * ERXDirectActionRequestHandler
 * ERXECNoValidationDelegate
 * ERXExtensions
 * ERXExtensions.Observer
 * ERXFileNotificationCenter
 * ERXFileNotificationCenter._ObserverSelectorHolder
 * ERXGraphUtilities
 * ERXLinlyn
 * ERXLocalizer
 * ERXLocalizer.Observer
 * ERXMessageEncoding
 * ERXNavigation
 * ERXNonPluralFormLocalizer
 * ERXRequest
 * ERXSession

Additional WOComponents

 * ERXBatchNavigationBar
 * ERXBatchNavigationBarInForm
 * ERXCheckboxMatrix
 * ERXCollapsibleComponentContent
 * ERXColoredTabPanel
 * ERXDebugMarker
 * ERXDHTMLComponent
 * ERXDirectActionHyperlink
 * ERXDirectActionImage
 * ERXDisplayDataAsString
 * ERXEditingContextInspector
 * ERXEditURL
 * ERXEmptyComponent
 * ERXEqualConditional
 * ERXErrorDictionaryPanel
 * ERXFakeRelationship
 * ERXFixedLengthString
 * ERXGraph
 * ERXGroupingRepetition
 * ERXGroupingTable
 * ERXHyperlinkKeyValueSetter
 * ERXImageTabPanel
 * ERXInstanceOfConditional
 * ERXJSAutoClosePage
 * ERXJSConfirmPanel
 * ERXJSCookiesConditional
 * ERXJSFormForTarget
 * ERXJSOpenWindowHyperlink
 * ERXJSOpenWindowSubmitButton
 * ERXJSPopUpRelationPicker
 * ERXJSPopupSelector
 * ERXJSTwoLevelEditToOneRelationship
 * ERXLinkRandomizer
 * ERXListContainsItemConditional
 * ERXListDisplay
 * ERXLocalizedString
 * ERXLog4JConfiguration
 * ERXMailTo
 * ERXMandatoryFieldMarker
 * ERXNonNullConditional
 * ERXNonZeroConditional
 * ERXDirectAction
 * ERXOptionalForm
 * ERXPluralString
 * ERXQueryRecentDates
 * ERXRadioButtonMatrix
 * ERXRepeatingTable
 * ERXSingleButton
 * ERXSortOrder
 * ERXStatelessComponent
 * ERXStringListPicker
 * ERXStringWithLineBreaks
 * ERXStyleSheet
 * ERXSuccess
 * ERXTable
 * ERXTableWithBorder
 * ERXTabPanel
 * ERXToManyRelationship
 * ERXToOneRelationship
 * ERXUnreadMarker
 * ERXWOForm
 * WOCollapsibleComponentContent
 * WOSortOrder
 * WOTable
 * WOTabPanel
 * WOToManyRelationship
 * WOToOneRelationship

EO Stuff

 * ERXDatabaseContextDelegate
 * ERXDefaultEditingContextDelegate
 * ERXEditingContextDelegate
 * ERXEntityClassDescription.Factory
 * ERXEventRecordingDefaultHandler
 * ERXSharedEOLoader
 * ERXTolerantSaver
 * ERXValidation
 * ERXValidationFactory

Logging

 * ERXEOFAppender
 * ERXLog4j
 * ERXLog4j.Observer
 * ERXLogger
 * ERXLogger.Factory

Utilities

 * ERXArrayUtilities
 * ERXCompilerProxy
 * ERXCrypto
 * ERXDictionaryUtilities
 * ERXFrameworkPrincipal
 * ERXKeyValuePair
 * ERXMacBinarySwissArmyKnife
 * ERXMultiKey
 * ERXMutableInteger
 * ERXProperties
 * ERXRetainer
 * ERXSimpleTemplateParser
 * ERXStringUtilities
 * ERXThreadStorage
 * ERXTimestampUtilities
 * ERXTimestampUtility
 * ERXUtilities


text:
WebObjects/Project WONDER/Frameworks/ERCalendar

Overview
Publish iCal files
 * ERCalendarEvent;
 * ERPublishCalendarPage;


text:
WebObjects/Project WONDER/Frameworks/ERChangeNotificationJMS

Overview
When deploying an application over multiple instances and machines, you need to be able to keep your Enterprise Objects in sync with each other. By including the ERChangeNotificationJMS framework achieves this with a couple of configuration settings in your Properties file.


text:
Wikijunior:Languages/Oriya

What writing system(s) does this language use?
Oriya uses the Oriya script which is somewhat similar to the Benagli script used for the Bengali language and the Devanagari script used for languages such as Hindi.

How many people speak this language?
About 31 million people.

Where is this language spoken?
Oriya (ଓଡ଼ିଆ oṛiā) is one of the Indian languages mainly spoken in the Indian state of Orissa, though there are also significant Oriya-speaking populations in other linguistic regions, such as the Medinpur district of West Bengal and the Saraikela Kharsawan district of Jharkhand. Due to the increasing migration of labour, the west Indian state of Gujarat also has a significant Oriya speaking population with Surat being the second largest Oriya speaking city in India. The language is also an official language of India.

What is the history of this language?
Oriya is an Indo-Aryan language and is thought to be directly descended from the Prakrit known as Purva Magadhi that was spoken in eastern India over 1,500 years ago. It bears a very strong resemblance to the modern languages Bangla (Bengali) and Ôxômiya (Assamese). Of all the languages spoken in northern India, Oriya appears to be the least influenced by Persian and Arabic.

Who are some famous authors or poets in this language?
Oriya has a rich literary heritage dating back to the thirteenth century. Sarala Dasa who lived in the fourteenth century is known as the Vyasa of Orissa. He translated the Mahabharata into Oriya. In fact the language was initially standardised through a procss of translation of classical Sanskrit texts like the Mahabharata, the Ramayana and the Srimad Bhagabatam. Jagannatha Das translated the Srimad Bhagabatam into Oriya and his translation standardized the written form of the language. Oriya has had a strong tradition of poetry, especially that of devotional poetry.

Prose in the language has had a late development. Distinguished prose writers of the modern period include Fakir Mohan Senapati, Manoj Das, Bibhuti Pattnaik, Pratibha Rai, Surendra Mohanty, Madhusudan Das, Kishore Charan Das, Kalindi Charan Panigrahi, Hari Hara Das, and Gopinath Mohanty. But it is poetry that makes modern Oriya literature a force to reckon with. Poets like Guruprsad Mohanty, Soubhagya Misra, Ramakanta Rath, and Sitakanta Mohapatra have made significant contributions towards Indian poetry.

title: Wikijunior:Languages/Oriya


text:
Talk:Introduction to Sociology/Sociological Methods

The reason that are mentioned in this book why according to Barker the Unification Church were accused of brainwashing are at best one-side and at worst erroneous. The public accused the Unification church of brainwashing because it offered a plausible all-encompassing explanation of a sudden adoption of weird beliefs. I am reading the book right now. 24.132.49.11 14:25, 20 May 2006 (UTC)

Also it should be noted that the public who accused the Moonies of brainwashing may not have used it in the way it was originally meant that is coerced conversion. In every day usage the term was and is often applied loosely. 24.132.49.11 14:29, 20 May 2006 (UTC)

Can you clarify this please?

The section "The Development of Social Science" on this page is largely identical to the similarly named section on the Introduction page. The two sections are basically identical except for the info about John Dewey in one version. Here are a couple links for reference.

http://en.wikibooks.org/wiki/Introduction_to_Sociology/Introduction#The_Development_of_Social_Science

http://en.wikibooks.org/wiki/Introduction_to_Sociology/Sociological_Methods#The_Development_of_Social_Science

I'm pointing this out without fixing anything or making specific suggestions, mainly because I don't have the knowledge to say where this information really ought to be. --72.141.21.242 15:33, 15 October 2006 (UTC)

To do
Expand the section on experiments to include an easy-to-understand model of the simplest experimental design. Add sections on:

1) participant observation and other fieldwork are the two options to collect information about the society

2) survey research; 3) content analysis;

Add links or content re examples of controversial or unethical research. Thomasfbrown (talk) 21:43, 3 November 2008 (UTC)


text:
WebObjects/Web Applications/Development/Ajax

Overview
Ajax (Asynchronous Javascript and XML) is a methodology of web programming based on Javascript code that makes requests to a webserver in the background of the page, and uses DHTML to provide on-the-fly updates without a full page refresh. The fundamentals of the request-response process are identical to that of a normal request, but to the end-user of your applications, you can create a web experience that is much closer to that of a native app.

While WebObjects has not been traditionally known for its Ajax support, the framework provides all of the groundwork necessary to build Ajax components and actions.

Ajax with DirectActions
Pierce T. Wetter III has written an extensive an excellent article comparing Ajax support in Ruby on Rails and Webobjects. In his article, he also provides examples of how one might integrate some of the popular Ajax libraries with WebObjects using Direct Actions.

Ajax framework
If you would like to get up-and-running more quickly, Project WOnder provides an Ajax framework (called, of course, Ajax.framework), which provide support for many common Ajax techniques like sliders, drag-and-drop, updatable areas, etc. For the base Ajax framework, there are no dependencies on any other frameworks in Project WOnder, so it's a great place to test the waters.

Related Reading

 * Programming Ajax
 * Ruby on Rails
 * Wikipedia Ajax Entry
 * Prototype Javascript library
 * Scriptaculous Javascript library


text:
WebObjects/Web Applications/Development/PDF Generation

Overview
You might want to also review the Returning a File example.

Zak Burke's Example
It is important to add "-Djava.awt.headless=true" to the "Additional Arguments" list to suppress a console window running WOBootstrap that will try to pop up and then fail to close, which seems to prevent the thread from returning, which causes the app to hang.

private ByteArrayOutputStream pdf {   // binary container for PDF ByteArrayOutputStream out = null; try {     // assume these exist String xsl, xml; TransformerFactory transformerFactory = TransformerFactory.newInstance; // configure FOP, apache's XML->PDF transformer Fop fop = new Fop(MimeConstants.MIME_PDF); out = new ByteArrayOutputStream; fop.setOutputStream(out); // configure XSLT transformer Source xsltSrc = new StreamSource(new StringReader(xsl)); Transformer transformer = transformerFactory.newTransformer(xsltSrc); // pipe XSL transformation through to FOP Result res = new SAXResult(fop.getDefaultHandler); // grab XML input stream Source src = new StreamSource(new StringReader(xml)); // Start the transformation and rendering process transformer.transform(src, res); }   catch (Exception e)    { // actually, catch the following, one by one: // TransformerConfigurationException // FOPException // TransformerFactoryConfigurationError // TransformerException }   return out; } public void appendToResponse(WOResponse response, WOContext context) {   ByteArrayOutputStream out = pdf; // without data, show the PDF page, which is just an error message. if (out == null) super.appendToResponse(response, context); // assume this exists String filename; response.setHeader("application/pdf", "Content-Type"); response.setHeader("" + out.size + "", "Content-Length"); response.setHeader("attachment;filename=" + filename, "Content-Disposition"); response.setContent(new NSData(out.toByteArray)); }

Related Links

 * FyTek Exe/DLL PDF Libraries
 * Big Faceless Organization - Java PDF Library & Report Generator
 * Java PDF Libraries
 * Apache FOP
 * Deirdre Saoirse Moen's FOP Example
 * JClass
 * Etymon PJ
 * PDFLib
 * PD4ML
 * iText
 * Hugi Karlmenn's iText Example
 * WebPDF Reports
 * XSL:FO Examples
 * ReportMill


text:
WebObjects/Web Applications/Development/CSS

Overview
CSS stands for Cascading Style Sheets. It's provides a mechanism to separate the presentation of your HTML page from the logical structure and content of your HTML page.

Style Block
The easiest way to include CSS in your WebObject application is put a style block in your tag:  table { border-style: solid; border-color: black; border-width: 1px; }

Static Reference
Another easy way to use CSS in your WebObjects application is to include a static reference to it with:

However, if you're a WO developer, you know static resource references feel dirty. Don't worry, there are alternatives.

Project WOnder
Project WOnder provides ERXStyleSheet, which is a stateless component with a template that can generate link tags for you.

Mike Schrag's MDTStyleSheet
The following dynamic element can be used to include a stylesheet in your page. It supports the bindings "rel", "type", "href", "src", etc similar to a WOImage. import com.webobjects.appserver.WOElement; import com.webobjects.appserver._private.WOConstantValueAssociation; import com.webobjects.appserver._private.WOHTMLURLValuedElement; import com.webobjects.foundation.NSDictionary; public class MDTStyleSheet extends WOHTMLURLValuedElement { public MDTStyleSheet(String _name, NSDictionary _assocationsDictionary, WOElement _template) { super("link", _assocationsDictionary, _template); if (_associations.objectForKey("rel") == null) { _associations.setObjectForKey(new WOConstantValueAssociation("stylesheet"), "rel"); }     if (_associations.objectForKey("type") == null) { _associations.setObjectForKey(new WOConstantValueAssociation("text/css"), "type"); }   }    protected String urlAttributeName { return "href"; } }

Stylesheet Component
Here is a trivial example on how to define style sheets properties at runtime:

Simply create a component with your style sheets properties:  a { color:  ; text-decoration:none; } a:hover { color: #ff9933; } a:visited { color:  ; } a:visited:hover { color: #ff9933; } body { margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; background-color:#FFFFFF; text-align:left; } input { font: 100% Verdana, Arial, san-serif; } .Title { font:  ; } .Label { font:  ; } .WhiteLabel { font:  ; color:#666666; } .Text { font:  ; } .MonoText { font:  ; } .Quote { font:  ; font-style: italic; margin-left: 20px; } .Line { height:1px; background-image:url( ); } .Space { height:8px; } .Highlight { background-color:#cccccc; } .DarkHeader { background-image:url( ); } .Header { background-image:url( ); } .Margin { width: 40px; vertical-align:top; } .Full { width: 100%; height: 100%; text-align:left; vertical-align:top; } .FullWidth { width: 100%; text-align:left; vertical-align:top; } .FillerWidth { width: 99%; text-align:left; vertical-align:top; } .FillerHeight { height: 99%; } .HalfWidth { width: 49%; text-align:left; vertical-align:top; } .OneThirdWidth { width: 33%; text-align:left; vertical-align:top; } .TwoThirdWidth { width: 66%; text-align:left; vertical-align:top; } .FixColumn { width: 250px; text-align:left; vertical-align:top; } .AltMargin { width: 40px; text-align:left; vertical-align:top; background-image:url( ); background-position: center center; background-repeat: no-repeat; }

And use some wod for the parameters: LinkColor: WOString{ value = linkColor; }; LineUrl: WOString{ value = lineUrl; }; DarkHeaderUrl: WOString{ value = darkHeaderUrl; }; HeaderUrl: WOString{ value = headerUrl; }; AltUrl: WOString{ value = altUrl; }; LabelFont: WOString{ value = labelFont; }; TextFont: WOString{ value = textFont; }; MessageFont: WOString{ value = messageFont; };

Related Links

 * CSS Programming
 * CSS on Wikipedia
 * W3 Schools on CSS


text:
Arimaa/Elephant and Minor Piece Attacks/Objectives and Risks

Reasons to use an Elephant and Minor Piece Attack

 * to capture enemy pieces in a trap that is defended only by weak pieces such as Cats and Rabbits
 * to create a counter-attack when the Camel and Horses are under attack on the opposite wing
 * to generate goal threats in the endgame
 * to facilitate the hostage-taking of a strong defender
 * to allow attacking opportunities for Horses and Camels by distracting the enemy Elephant
 * because all the Horses and Camels have been exchanged off the board
 * to blockade the enemy position (see chapter on Multiple Piece Swarming Attacks)

Risks associated with Elephant and Minor Piece Attacks

 * multiple weak attackers may be taken hostage or framed
 * if the Elephant is forced to move to another quadrant, pieces may be trapped
 * the home trap defense may be seriously weakened and the goal defense may be compromised
 * hostage-taking attempts decentralize the attacking Elephant
 * the attacking side may not be able to hold the crucial b6 square
 * an Elephant and Rabbit Attack is likely to result in the Rabbit being framed on the c6 square, unless the trap is defended only by Rabbits


text:
Arimaa/Attacking/Example: Elephant–Dog Attack

In the opening of, Silver paid little attention to the c6 trap. An elephant-dog attack was thus enough to get Gold ahead while the gold horses and camel defended at home.

After 10s, Silver had a potential threat on each wing. Unable to immediately hostage the silver camel, Gold blockaded the advanced silver horse with 11g Dc2n Rc1n Hb3w Dc3w. Rather than pursuing a threat in the east, Silver played 11s ee3ws mg4n Hg3n, aiming to unblock his horse and attack the c3 trap. Gold responded with 12g Rh3n Hg4s Eb5ee, protecting his eastern horse and camel while also centralizing his elephant, which was now a potential threat to the silver camel on g5 and the dog on d6.

On 12s, Silver ignored his increasingly weak northwestern defense, and continued to attack the southwest with 12s ed2n Rc2e Rb2e ha2e. However, Gold had a clever two-turn plan in mind. 13g Cd1w Db3n Ha3e Ra1n delayed the silver attack on c3, and also positioned the western gold dog to attack c6. On 12s or 13s, Silver could have unfrozen the d6 dog and moved it to b6, thus blocking the gold dog from that square; had the western gold horse then advanced, Silver could have owned c3. Instead, play continued 13s Rc2n hb2e ed3e mg5e 14g Db4nn dd6n Ed5n.

Gold has taken control of c6. An opening attack would normally require more strength, but since there was nothing to stop the western gold dog, Gold advanced it and kept his home defense strong. Silver could now defend c6 only by moving his elephant to c5, but that would leave the c2 horse vulnerable to the gold camel, which could then freeze it while a gold rabbit helped to defend c3. From the current position, Silver cannot avoid a loss in the west; Silver must cede c6 and counterattack elsewhere. The h4 rabbit could be dragged toward f6 and captured in two turns, but in that time Gold could capture a silver cat and dog in c6. Instead, Silver attacked f3 with 14s mh5ws Hg3e mg4s, but Gold defended with a single step and also captured the c7 cat: 15g Mf3n Db6n cc7sx Db7e. Silver then created a double threat in the east, but Gold defended both traps, and the gold dog remained a strong attacker on c7.


text:
How to use a Motorola DVR/Using Passport Echo

This page (and probably subpages) will contain general information on using the DVR (using the tuners, setting up and playing recordings, etc..) for those programmed with Passport Echo.

As always, do NOT simply copy text or images from a manual! That is a copyright violation!!


text:
User:Aishazoe

Bonjour tout le monde! My name is Aisha, but some call me Zoe, depending on how well you pronounce my reall name :). I'm currently living in Las Vegas watching my degree in Music and French gather dust.

I just got my letter that I will be teaching high school English in the Academy of Bordeaux. I've done study abroad in Pau and Bayonne for one summer, and it was such a great time I decided to come back! I have another friend who'll be an assistant in the same region, so if anyone needs advice or just to hang out once there, drop me a line!

A plus!

Teaching Assistant in France Survival Guide/Directory

title: User:Aishazoe


text:
WebObjects/EOF/Using EOF/Compound Primary Keys

Sacha Mallais
Generally avoid them. However, when you need them you can usually use the Propagate Primary Key feature to avoid having to do anything fancy.

Writing a delegate to generate PKs from the database is not a bid deal (see GVCEOFExtensions for an example of an integer PK caching delegate).


text:
WebObjects/Web Applications/Development/Thumbnailing

Overview
Many people have asked how to create thumbnails of images using WebObjects. There is nothing specific to WebObjects about this problem, and there are quite a few options for solving it:

 * On Mac OS X, you can use Runtime.exec(..) and call the commandline program "sips," which uses the ImageIO and CoreImage frameworks
 * On Mac OS X, you can use Brendan Duddridge's ImageIO JNI Wrapper
 * An all platforms, you can use Java2D with Java's ImageIO and BufferedImage
 * On many platforms, you can run ImageMagick and use Runtime.exec to call the commandline "convert"
 * On many platforms, you can build and run JMagick, a Java JNI wrapper around ImageMagick

ImageMagick
A utility class to call ImageMagick binaries as an external process with Runtime.exec, to either discover height/width or resize an image. It has a few default filepaths that correspond to what I need on my systems, you probably want to change them for your system(s).

''Anjo Krank: I may be wrong, but I'm pretty sure that this code won't work, at least not reliably. There is no guarantee that the contents of the supplied arrays are filled before the process exits. I had a lot of null-results when I tried this in Wonder. The only safe way I've seen so far is to actually wait until the stream is truly finished reading before accessing the result. And this can only be done by waiting on a sema. Take a look at ERXRuntimeUtilities for a version that does work.''

/* ImageMagickUtil.java created by jrochkind on Thu 24-Apr-2003 */ import com.webobjects.foundation.*; import com.webobjects.eocontrol.*; import com.webobjects.eoaccess.*; import com.webobjects.appserver.*; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; /* Utility methods that deal with images by calling the ImageMagick software as an external process */ /* Dealing with Runtime.exec in a thread-safe way is tricky! Sorry for that. I used the article at http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html as a guide for understanding how to do it right. */ public class ImageMagickUtil { //protected static final String imUtilLocationPath = "C:\\Program Files\\ImageMagick-5.5.6-Q8\\"; protected static final String imUtilLocationPath;// = "/export/home/jar247/mtBin/"; //The image util location path can be supplied as a Java property, //or we can try to guess it from the OS. static { String locProp = System.getProperty("imUtilPath"); String osName = System.getProperty("os.name"); if ( locProp != null ) { imUtilLocationPath = locProp; }       else if ( osName.indexOf("Windows") != -1 ) { imUtilLocationPath = "C:\\Program Files\\ImageMagick-5.5.6-Q8\\"; }       else { //Assume our deployment machine, which is currently set up           //to make this the location... imUtilLocationPath = "/export/home/webob/ImageMagick/bin/"; }   }    protected static final String imIdentifyCommand = "identify"; protected static final String imConvertCommand = "convert"; public static ImageProperties getImageSize(String filePath) throws IMException { return getImageSize( new java.io.File(filePath) ); }   public static ImageProperties getImageSize(java.io.File imageFile) throws IMException { String filePathToImage = imageFile.getPath; String[] cmdArray = new String[] { imUtilLocationPath + imIdentifyCommand, "-format", "%w\n%h", // [width][newline][height] filePathToImage };       NSMutableArray stdOutContents = new NSMutableArray; NSMutableArray stdErrContents = new NSMutableArray; int resultCode = -1; try { resultCode = exec(cmdArray, stdOutContents, stdErrContents); }       catch (IOException ioE ) { //For some reason we couldn't exec the process! Convert it to an IMException. //One reason this exception is thrown is if the path specified to the im           //executable isn't correct. throw new IMException("Could not exec imagemagick process: " + ioE.getMessage, cmdArray, null); }       catch ( InterruptedException intE ) { //re-throw it as an IMException. //This exception should really never be thrown, as far as I know. throw new IMException("imagemagick process interrupted! " + intE.getMessage, cmdArray, null); }       if ( resultCode != 0 ) { //The external process reports failure! IMException e = new IMException("Identify failed! ", cmdArray, stdErrContents); e.exitValue = resultCode; throw e;       } //Now we need to parse the result line for the height //and width information. if ( stdOutContents.count >= 2 ) { //First line is width, second is height, because //we asked the imagemagick 'identify' utility to           //output like that. String widthStr = (String) stdOutContents.objectAtIndex(0); String heightStr = (String) stdOutContents.objectAtIndex(1); Integer width = new Integer( widthStr ); Integer height = new Integer( heightStr ); ImageProperties p = new ImageProperties; p.width = width; p.height = height; return p;       } else { //Umm? Error condition. throw new IMException("Unexpected output of imagemagick process", cmdArray, stdErrContents); }   }    // An external image magick process will be run to resize the image. It's recommended you // check to make sure it's necessary to resize the image first! // Beware, if the sizes you pass in are LARGER than the existing size, the output image // WILL be BIGGER than the input---this isn't just for resizing downward. // Null outFilePath means to overwrite the source file path with the resized image. // You can pass null for either maxWidth or maxHeight, but not both, that would be silly! // [not implemented yet:] Returned is an object telling you the new resized size of the output image. public static void resizeImage(String sourceFilePath, String outFilePath, int maxWidth, int maxHeight) throws IMException { if ( outFilePath == null ) { //overwrite original file if necessary outFilePath = sourceFilePath; }       /*else if ( NSPathUtilities.pathExtension( outFilePath ) == null ) { //give the output file path the same extension as the in file path. outFilePath = NSPathUtilities.stringByAppendingExtension( outFilePath,                                                                     NSPathUtilities.pathExtension(sourceFilePath)); }*/       StringBuffer dimensionBuffer = new StringBuffer; if ( maxWidth != -1) { dimensionBuffer.append(maxWidth); }       dimensionBuffer.append( "x" ); if ( maxHeight != -1) { dimensionBuffer.append( maxHeight ); }       String dimensionDirective = dimensionBuffer.toString; //We include the ' +profile "*" ' argument to remove //all profiles from the output. Not sure exactly what this means... //but before we were doing this, we wound up with JPGs that //caused problems for IE, for reasons I do not understand. String[] cmdArray = new String[] { imUtilLocationPath + imConvertCommand, "-size", dimensionDirective, sourceFilePath, "-resize", dimensionDirective, "+profile", "*", outFilePath };       NSMutableArray stdErrContents = new NSMutableArray; NSMutableArray stdOutContents = new NSMutableArray; int resultCode; try { resultCode = exec( cmdArray, stdOutContents, stdErrContents ); }       catch (IOException ioE ) { //For some reason we couldn't exec the process! Convert it to an IMException. //One reason this exception is thrown is if the path specified to the im           //executable isn't correct. throw new IMException("Could not exec imagemagick process: " + ioE.getMessage, cmdArray, null); }       catch ( InterruptedException intE ) { //re-throw it as an IMException. //This exception should really never be thrown, as far as I know. throw new IMException("imagemagick process interrupted! " + intE.getMessage, cmdArray, null); }       if ( resultCode != 0 ) { //The external process reports failure! IMException e = new IMException("Conversion failed! ", cmdArray, stdErrContents); e.exitValue = resultCode; throw e;       } }   //Invokes the external process. Puts standard out and standard error into the //arrays given in arguments (they can be null, in which case the err/out stream   //is just thrown out.    //Throws IOException if the exec of the external process doesn't work, for instance    //because the path to the command is no good.    //Throws the InterruptedException... not sure when, if ever. But it means that the exec    //didn't work completely.     public static int exec(String[] cmdArray, NSMutableArray stdOut, NSMutableArray stdErr) throws IOException, InterruptedException {        Process process = Runtime.getRuntime.exec( cmdArray );                //We are interested in what that process writes to standard        //output and standard error.        //Grab the contents of those in their own separate threads!        //To avoid deadlock on the external process thread!        StreamGrabber errGrabber = new StreamGrabber( process.getErrorStream, stdErr );        StreamGrabber outGrabber = new StreamGrabber( process.getInputStream, stdOut ); errGrabber.start; outGrabber.start; return process.waitFor; }   //Will launch a NEW THREAD and put the contents of the given stream into //the NSMutableArray. Don't be accessing the array in another thread before //we're done! //If array is null, StreamGrabber reads the input stream to completion, //but doesn't store results anywhere. static class StreamGrabber extends Thread {       InputStream inputStream; NSMutableArray array; boolean done = false; Exception exceptionEncountered; StreamGrabber(InputStream is, NSMutableArray a)       { super("StreamGrabber"); this.inputStream = is; this.array = a;       } public void run {           try { InputStreamReader isr = new InputStreamReader(inputStream); BufferedReader br = new BufferedReader(isr); String line=null; while ( (line = br.readLine) != null) {               if ( array != null ) { array.addObject(line); }           }            }            catch ( java.io.IOException e) { //hmm, what should we do?!? setExceptionEncountered( e ); }           setDone( true ); }       public synchronized void setDone(boolean v) { done = v;       } //Can be used by parent thread to see if we're done yet. public synchronized boolean done { return done; }       public synchronized Exception exceptionEncountered { return exceptionEncountered; }       public synchronized void setExceptionEncountered(Exception e) { exceptionEncountered = e;       } public boolean didEncounterException { return exceptionEncountered != null; }   }    //Exception thrown by utility methods when the call to an external image magick //process failed. public static class IMException extends Exception { protected int exitValue; protected String processErrorMessage; protected String invocationLine; protected String message; public IMException { super; }       public IMException(String s) { super; message = s;       } //Constructs a long message from all these parts public IMException(String messagePrefix, String[] cmdArray, NSMutableArray stdErr) { super; if ( cmdArray != null ) { invocationLine = new NSArray( cmdArray ).componentsJoinedByString(" "); }           if ( stdErr != null ) { processErrorMessage = stdErr.componentsJoinedByString("; "); }           StringBuffer b = new StringBuffer; b.append( messagePrefix ); b.append(". invocation line: "); b.append( invocationLine ); b.append(". error output: " ); b.append( processErrorMessage ); message = b.toString; }       //the return code from the image magick external invocation. //I think it's probably always 1 in an error condition, so not so useful. public int exitValue { return exitValue; }       //The error message reported by image magick. public String processErrorMessage { return processErrorMessage; }       //The command line used to invoke the external im process that //resulted in an error. public String invocationLine { return invocationLine; }       public void setInvocationLine( String[] cmdArray ) { invocationLine = new NSArray(cmdArray).componentsJoinedByString(" "); }       //over-riding public String getMessage { return message; }   }    //Object that encapsulates data returned by an image operation public static class ImageProperties extends Object { protected Integer height; protected Integer width; public ImageProperties { super; }       public Integer height { return height; }       public Integer width { return width; }   }  }

JAI example
An example how to resize an image with Java Advanced Imaging (http://java.sun.com/products/java-media/jai/). The jar files jai-codec.jar and jac-core.jar are in the NEXT_ROOT/Library/Java/Extensions folder and referenced in the classpath. This example uses logging capability from project wonder.

/* ImageResizer.java */ import java.awt.image.renderable.ParameterBlock; import java.io.ByteArrayOutputStream; import java.io.IOException; import javax.media.jai.InterpolationNearest; import javax.media.jai.JAI; import javax.media.jai.OpImage; import javax.media.jai.RenderedOp; import com.sun.media.jai.codec.ByteArraySeekableStream; import com.webobjects.foundation.NSData; import er.extensions.ERXLogger; public class ImageResizer { private static final ERXLogger log = ERXLogger.getERXLogger(ImageResizer.class); /**    * utility function to resize an image to either maxWidth or maxHeight with jai * example: logo = new NSData(aFileContents1); *         logo = ImageResizer.resizeImage(logo, 128, 42); * @param data image content in NSData array * @param maxWidth maxWidth in pixels picture * @param maxHeight maxHeight in pixels of picture * @return resized array in JPG format if succesfull, null otherwise */   static public NSData resizeImage(NSData data, int maxWidth, int maxHeight) { try { ByteArraySeekableStream s = new ByteArraySeekableStream(data                   .bytes); RenderedOp objImage = JAI.create("stream", s); ((OpImage) objImage.getRendering).setTileCache(null); if (objImage.getWidth == 0 || objImage.getHeight == 0) { log.error("graphic size is zero"); return null; }           float xScale = (float) (maxWidth * 1.0) / objImage.getWidth; float yScale = (float) (maxHeight * 1.0) / objImage.getHeight; float scale = xScale; if (xScale > yScale) { scale = yScale; }           ParameterBlock pb = new ParameterBlock; pb.addSource(objImage); // The source image pb.add(scale); // The xScale pb.add(scale); // The yScale pb.add(0.0F); // The x translation pb.add(0.0F); // The y translation pb.add(new InterpolationNearest); // The interpolation objImage = JAI.create("scale", pb, null); ByteArrayOutputStream out = new java.io.ByteArrayOutputStream; JAI.create("encode", objImage, out, "JPEG"); return new NSData(out.toByteArray); } catch (IOException e) { log.error("io exception " + e); } catch (RuntimeException e) { log.error("runtime exception "+e); }       return null; } }


text:
User:9riffin

9riffin is currently a 20 year old student, but hopes to one day become a 21 year old student. He suffers an interminable frustration from his inability to speak a second language or posses any creative talent what so ever.

The best method for contacting him is through his e-mail, (his user name)@gmail.com or by adding the same address on msn.

title: User:9riffin


text:
WebObjects/Additional Resources/Books

Beginning Xcode and WebObjects: From Novice to Professional
This book has been cancelled. We are planning on writing a book like "Beginning WebObjects: From Novice to Professional", but it will be based on Eclipse and WOLips. This is not yet underway, so please don't ask about the schedule. -- Chuck

Practical WebObjects
Practical WebObjects is a must-have book for anyone who is serious about WebObjects development. Chuck Hill, of WebObjects mailing list fame, covers a huge number of topics that will be useful at almost any level of WebObjects development. In particular, his coverage of the request-response loop is one of the best explanations available.

Professional WebObjects with Java
WebObjects 5 is the powerful new release of Apple's award-winning application server, built from the ground up in Java. This allows WebObjects to run on virtually any server making it easily accessible to millions of Java programmers. WebObjects also integrates with other Java-based solutions such as EJB containers, servlets, ORBs, and web services. The combination of a Java runtime with advanced native tools for Mac OS X and Windows 2000 makes WebObjects an obvious environment for customers needing rapid development of flexible, scalable web applications.

This book covers:

Complete guide to installing and using WebObjects 5.0 Multi-platform approach, for WebObjects running on either Mac OS X or Windows 2000 Comprehensive tour of WebObject's application development tools Creating WebObjects components Object-relational mapping to databases using the Enterprise Object Framework Advanced features including Direct To Web and Java Client Practical worked examples throughout, including a detailed case study

You will get the most from this book if you are an experienced Java software developer with an interest in building sophisticated, database-driven web application using WebObjects. Apple has applied all their graphical user interface expertise to make using WebObjects pretty straightforward, but to unlock its potential, a thorough understanding of Java is needed.

title: WebObjects/Additional Resources/Books


text:
WebObjects/EOF

WebObjects has two facets. One facet takes a relational database, or some other persistent data source, and turns it into an object graph, a group of objects that connect to each other. Another facet takes an object graph and uses templates to produce HTML. The first facet is EOF. EOF bridges the world of relational databases to the world of objects. To put it in other terms, EOF allows you to start with a database and build POJOs (POJO = "Plain Old Java Object") that represent the things you want to do on top of your database, to make it smarter and more responsive to your desired audience.

If you have come from a relational database environment, you may have been trained to think in terms of tables, rows, columns, joins, Cartesian cross products, result sets and the like. So long as you continue to view your applications in those terms, WebObjects will stubbornly stand between you and success by imposing an extraordinary number of "conveniences" in your way to a quick SQL solution to your immediate problem. The schema design under your application is important, but the schema design is not the same as the database design. EOF gives you a layer of abstraction over a simple relational database.

If you can wrap your mind around the object-oriented concepts, using the object-oriented collection classes, such as arrays (or vectors), sets, dictionaries (or hash tables) and think in terms of the object graph with which you're working, you will find WebObjects to be a very supportive and helpful technology. Like all complex technologies, it has its glitches and bugs, but they are surprisingly few for the incredible complexity underlying the surface.

There are two ways to approach using EOF. It is used both as a way to make existing databases more flexible or as a way to perist models in applications being developed. It is used both by entrepreneurs who model on a whiteboard first and write code last, and by companies with 15 year old databases and legacy code and systems that have to be made more flexible.

If you already have a database, the best way to get started is to reverse engineer a model. If you have WebObjects on a Mac OS X system, you have an example database and a JDBC driver for it.

The best way to get a handle on what WebObjects may be for you is to take a long hard look at your EOModel as an ER diagram. Open your EOModel in EOModeler and switch to the graphic Entity-Relationship view (the little pop-up in the upper left corner of the EOModeler window). That view represents the object graph of your model objects. Rearrange the entities by dragging to get as little line crossing as possible so you can see the diagram clearly. Once you've done that, you might want to print it out to make access more convenient. An easy way to do this, if you're on a Mac, is to take a screen shot of it and then you can print out the resulting .pdf file and have it scaled to a single sheet of paper.

Note that the names of the attributes in each of the entities on that diagram are the official EOModel "attribute" names rather than the database column names. EOModeler will create a java class file for each of those entities, if you ask it to, and the java member names (ivars and method names) will correspond to those names as well. This is the first step to thinking in the WebObjects way. Think in terms of those official "attribute" names for any operation rather than the database column names.

Once you have wrapped your mind around the model, the next step is getting some data. Pick an entity in which you're interested. To instantiate a set of objects in your application for that entity, you've typically got to create an EOQualifier to select the appropriate instances from all the instances that are out there in your object store (notice I said object instances, not table rows, and object store, not relational database; gotta get used to thinking objects).

Say you have a set of Employee and Department records out there and you want to get all the Employees who work for your department to send them invitations to the division end-of-year-blow-out (EOYBO). Further, assume that your Employee and Department entities have the following attributes:

Employee lastName firstName lengthOfService ... Department name location division

If you just wanted employees of a given gender, say, "female", the easiest way to get them would be to use EOUtilities as a handy short cut for easy queries.

myEditingContext = session.defaultEditingContext; NSArray femaleEmployees = EOUtilities.objectsMatchingKeyAndValue(myEditingContext, "Employee", "gender ", "female");

There's a lot there, but you can look up the method in the documentation for EOUtilities to see what the arguments mean. In any case, once this statement is executed, you have an NSArray of the employees you're looking for. (look NSArray up too and compare it to Java's Array or Vector which are similar). Unfortunately, just comparing to a given attribute by a specific value is a bit confining, so the longer, but more flexible, way is to create an EOQualifier, then use it in a fetch specification to get your initial objects. The easiest way to create your qualifier is with the magic method, "qualifierWithQualifierFormat". With these tools, we can get the employees we were first looking for, that is, those in our department. Let's do that like so:

myDepartmentName = "Information Technology"; EOQualifier myQual = EOQualifier.qualifierWithQualifierFormat("department.name = %@", myDepartmentName); EOFetchSpecification myFetcher = new EOFetchSpecification("Employee", myQual, null); EOEditingContext myEC = session.defaultEditingContext; NSArray employeesToInvite = myEC.objectsWithFetchSpecification(myFetcher);

Once again, we end up with an array of Employees but using a slightly harder approach. Notice, however, that we've asked the database to do a join for us by using that little "department.name" construct in the qualifier format. That says, get the employee connected to a department object whose name is... The advantage, of course, is that the magic method, qualifierWithQualifierFormat allows us to build some pretty complex qualifiers, and allows us to do so easily, such as:

EOQualifier myQual = EOQualifier.qualifierWithQualifierFormat("(department.name = %@ and age > %@ and boss.gender = %@) or gender = 'female'", myDepartmentName, new Integer(40), "male");

The hard part is done. Now we only have left the stuff that WebObjects makes so easy for us as an object-oriented programmer. Suppose that for each of these employees, you wanted to schedule them for the EOYBO by sending messages to their bosses. Presume also, that bosses, like employees, are Employees, so have the same attributes shown above. Simply iterate through your array of Employees and ask each object for its boss's email address and send off the invitation, like so:

Enumeration enum = likelyEmployees.objectEnumerator; while (enum.hasMoreElements) { Employee anEmployee = enum.nextElement; sendScheduleRequestTo(anEmployee.boss.emailAddress); }

Notice that we didn't need any more fetch specifications or qualifiers! WebObjects, through its Enterprise Objects Framework, automatically recognizes the need for more records from the database (the bosses) and just goes and gets them for us without the need for more explicit fetching.

Granted, someone would have to write the method, "sendScheduleRequestTo(EMailAddress addr)", but there are lots of libraries available, and you probably know Java well enough to do that yourself.

The point is, we don't have to do an extra explicit fetch for the bosses because WebObjects does it for us. It basically does the join operation and provides us the result invisibly. Just get your first set of objects with a fetch, then follow the object graph.

Forget result sets, joins, selects and all the rest of those relational database artifacts. Or, at least, forget them till you get in trouble, somehow, obtaining the results you're looking for. If the trouble is deep enough, set the WebObjects runtime parameter, -EOAdaptorDebugEnabled YES, and the EOAdaptor will dump all the SQL it generates out onto your run log, so you can see exactly what it's doing for (or to) you. :-)

Before you go off and build your first critical, human-life-hangs-on-no-bugs WebObjects program, however, you should have a look at "General Guidelines for Managing the Object Graph". This goes a little deeper into some of the concepts I've referenced here and is written very well.

You can find it in the Apple documentation at: /Developer/Documentation/WebObjects/Reference/API/com/webobjects/eocontrol/concepts/EOEditingContextConcepts.html#GENERALGUIDELINES

or

/Developer/ADC Reference Library/WebObjects/Reference/API/com/webobjects/eocontrol/concepts/EOEditingContextConcepts.html#GENERALGUIDELINES

That, of course, is an HTML fragment of a much larger page, all of which is worth reading.

In any case, good luck with your WebObjects future.

Class References:

 * http://developer.apple.com/documentation/WebObjects/Reference/API/com/webobjects/eoaccess/EOUtilities.html

title: WebObjects/EOF