struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Thomas Sattler <tomsatt...@gmail.com>
Subject Struts Dojo Question
Date Sat, 14 Nov 2009 02:03:05 GMT
Hello all.

In working through some Dojo stuff, I have come to a roadblock, on which I
hope someone will be able to shed some light.

I have a page that displays a user's account info.  If they press "update",
Dojo pops up a dialog box which allows them to update their info.  Opening a
Dialog box in a web browser is very cool, and it's easy to do with Dojo.

In the dialog, there is are three dropdown boxes, named "Continent",
"Country", and "Locality".  If the user chooses the continent of "North
America", the "Country" box should show only the countries for North
America.  If the user chooses "Western Europe", the "Country" box should
show only the countries for Western Europe.  And so on; you get the idea.

I am using the standard Json ItemFileReadStore attached to my Postgres
database.  The "Continent:" field gets filled properly.  But when I select a
different "Continent", and the call is made to the Action class to retrieve
the list of countries for the new continent, the new continent's
abbreviation is never passed in.

My javascript reads like so:

var selectedContinent ;
    function continentWasChanged()
    {    selectedContinent = dijit.byId('continent').attr('value') ;
        console.log ('found selectedContinent as ' + selectedContinent) ;
        theStore.fetch(selectedContinent) ;
    }

The "console.log" statement shows that selectedContinent DOES have the value
I expect.

The intention is to have the selectedContinent passed into my action class.

My struts.xml snippet reads like so:

        <action name="countryData" method="countryData"
class="LocationAction">
        <result name="NONE"></result>
                <param name="continent">#attr.selectedContinent</param>
        </action>

In my LocationAction class, I have a "setContinent(String)" method, and the
passed parameter is the string "#attr.selectedContinent", not "NA" when
North America is selected.
In going through the OGNL docs, I thought that "#attr" is the way of
selecting data on a page, but maybe not in this case, because the
LocationAction class is only used to serve up locations.  The jsp is really
"bound" to the UserDisplayAction class.  I'm thinking if I move the Action
logic into the UserDisplayAction class, it might work better, but I hope I
can separate the logic in this fashion.

I guess the question is whether it is possible to do what I am trying to do
here, or not?

Thanks,
Tom

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message