Steve Hall

Greenhorn
+ Follow
since Feb 28, 2011
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Steve Hall

Hope someone can help me although this might be a bit more xslt based than java but there don't really seem to be many xslt forums
I am trying to call a java function from within an xslt, a little background.

The xslt is displaying a page to users that in what part of it is a table of information with a checkbox in each row. When the row is selected an element in the xml switches from 0 to 1

<xsl:attribute name="onclick">
containerSelectorCheckBox(this,<xsl:value-of select="$AttrId"/>,<xsl:value-of select="$ColumnId"/>,<xsl:value-of select="$RowIdx"/>)
</xsl:attribute>
<xsl:if test="$RowIsSelected=1">
<xsl:attribute name="checked">checked</xsl:attribute>
</xsl:if>

A snippet of the xml

<Rows>
<Row>
<Idx>0</Idx>
<CanDelete>1</CanDelete>
<CanEdit>0</CanEdit>
<CanCopy>1</CanCopy>
<IsSelected>1</IsSelected>

The javascript function will change the IsSelected from 0 to 1


Now What I am trying to do is instead of calling this function on a click, to call it for all Row Elements and automatically select them by default with no way to de-select them. Unfortunately there is no way to have the base xml default to 1 which would be by far the easiest. I have tried calling this function just within <script></script> but caused some massive issues.

Can anyone provide some advice on how to proceed, the java function works entirely I just need to call it in such a way that it is called on an event other than click.

Thank you.
6 years ago
sorry i meant having two subclasses in the array.

So superclass is electronics

with a subclass of TV, and Computer

The array contains both TV's and Computers. So the array is of the electronics type.

Since it is of type electronics you can put both TV's and Computers inside of it. However you can't access the methods for TV or Computer. Just the Electronics methods.

Maybe it's just the book, but it made it sound that it was useful to have a bunch of different related subclass objects inside one array. So instead of having a separate array for each subclass there is just one big overreaching one. So say i had subclasses TV, Computer, Phone, Stereo. And I want to put all of them in one big array. Say it was all the electronics in my home and I wanted to perform something on all of them.

I have an array of type Electronics and it contains a bunch of different objects inside of it



in this situation would I use abstract methods for Electronics? It just seems like it would be useful to be able to group everything together into one array, but not at the expense of destroying functionality. I am just worried it could get messy if there are a ton of subclass types that have specific methods volumeUp, volumeDown, goToSleep, I wouldn't want to have a giant list of abstract methods in the Electronics class I don't think.

I guess it is mainly a lack of me knowing real world project structure. I can get it to work, but I like knowing the right way to get it to work.
8 years ago
Ok so I found a post on here that helped me out a little.

Say I have:




now say I make an Array of type Electronics



as I understand it if I try doing gadgets[0]. i would only get the methods in the Electronics class unless I casted it as a type Television.

Why then would you want to make an array that can contain multiple types? I mean it seems useful at first. I could have an array of electronics that contains televisions, computers, phones and so forth. But if I can't call the methods of these specific types why bother? In normal implementation do you cast it as the appropriate type every time? I could see this leading to mismatching problems pretty easily unless you are very careful.

I think I have the what happens part down I just am not sure about the reason why this is useful, why would I ever type a subclass object as a superclass if i can't access it's methods.

Forgive me if I get some terminology wrong this is my first week in learning Java.
8 years ago