Struts Logic Problem
Why doesn't the code below work? The idea is that the page checks to see if the dropdown variable has changes since you last refreshed the page.
<logic:equal name="Result" value = "-1">
<bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate"
type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:equal name="Result" value = "-1">
<bean:define id="DropDownValue" name="smlMoverDetailForm" property="moverChangeType"
type="java.lang.String" toScope = "session" />
</logic:equal>
<-- when you fisrt access this page from the above are run -->
<bean:define id="NewDropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "sess
<-- this happens everytime the page is refreshed-->
<logic:equal name= DropDownValue value = NewDropDownValue>
<bean:define id="JOININGDATE" name="smlMoverDetailForm"
property="empFDJoiningDate" type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:notEqual name="DropDownValue" value = "NewDropDownValue">
<bean:define id="DropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "session"
/>
</logic:notEqual>
Asked by: Kimberly588 | Posted: 28-01-2022
Answer 1
You have realized, that your bean:define - at least in your question stated here - is flawed?
toScope="sess
is most likely not what you want - it doesn't even terminate the tag. But this may be formatting in StackOverflow... Also, the missing quotes have been mentioned in other answers.
The error may be the use of the value property: According to http://struts.apache.org/1.2.x/userGuide/struts-logic.html#equal value is The constant value to which the variable, specified by other attribute(s) of this tag, will be compared.
Thus, given that you've defined a bean named NewDropDownValue you might want to evaluate
<logic:equal name="DropDownValue" value="<%=NewDropDownValue/>">
Edit: Additionally I can't remember what happens when you only conditionally define a bean - your bean is defined inside a logic:equal block that might or might not be evaluated. It might be legal and have defined results, I just can't remember...
Answered by: Dainton452 | Posted: 01-03-2022Answer 2
<logic:equal name= DropDownValue value = NewDropDownValue>
I'm not sure if this is your problem (describe how it doesn't work please), but the above is not valid xml: it needs quotes around the attribute values.
Answered by: Walter360 | Posted: 01-03-2022Answer 3
The problem is as your describe i can't get the logic tags to evaluate the values held in the defined beans.
Answered by: Rafael441 | Posted: 01-03-2022Answer 4
Actually, I don't really get what you want, but here's some pseudocode (removing those dangerous pointy brackets) of your code in the question
if result == -1
define JOININGDATE
end
if result == -1
define DropDownValue
end
This might be an error (you might want to check once for 'equals' and once for 'does not equal') or be written shorter and more clear
if result == -1
define JOININGDATE
define DropDownValue
end
// otherwise don't define both values
Your question might get better answers (or be answered by you yourself) if you placed some output inside of those logic tags and post both the output and a bit more of the context (e.g. actual parameter values -- what is 'Result'). But then - you've posted from an unregistered account and have not been seen for some time...
Answered by: Haris998 | Posted: 01-03-2022Answer 5
Try this:
<logic:equal name="Result" value = "-1">
<bean:define id="JOININGDATE" name="smlMoverDetailForm" property="empFDJoiningDate"
type="java.lang.String" toScope = "session" />
</logic:equal>
<logic:equal name="Result" value = "-1">
<bean:define id="DropDownValue" name="smlMoverDetailForm" property="moverChangeType"
type="java.lang.String" toScope = "session" />
</logic:equal>
<!-- when you fisrt access this page from the above are run -->
<bean:define id="NewDropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "session"/>
<!-- this happens everytime the page is refreshed-->
<logic:equal name="DropDownValue" value="<%=request.getSession().getAttribute("NewDropDownValue").toString()%>">
<bean:define id="JOININGDATE" name="smlMoverDetailForm"
property="empFDJoiningDate" type="java.lang.String" toScope ="session" />
</logic:equal>
<logic:notEqual name="DropDownValue" value="NewDropDownValue">
<bean:define id="DropDownValue" name="smlMoverDetailForm"
property="moverChangeType" type="java.lang.String" toScope = "session"/>
</logic:notEqual>
Errors corrected:
- Comments were not well formed
- Third was not correctly ended
- Change the way to get NewDropDownValue
I think those changements will make it runs correctly.
Answered by: Wilson646 | Posted: 01-03-2022Similar questions
java - Problem with Commons Logging / Log4j setup in spring webapp with tomcat 6
I have a problem wih a logging setup in a apring webapp deployed under tomcat 6.
The webapp uses the commons-logging api, on runtime log4j should be used. The log file is created but remains empty - no log entries occur.
the setup is the following:
WEB-INF/web.xml:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4...
java - Problem with applet loading on Mac OS x 10.4
I have been working on web application which includes java applet. My app is working fine on PC with different browsers like IE and Firefox. The web application hosted on Linux (Ubuntu).
I had problem on Mac with Firefox. I was unable to load the applet.
This is the error i found in java console.
Java.lang.classNotFoundException web/applets/ImageObsApplet.class
I have hosted the web application on PC windows ...
java - Help I have problem with select query in JPA
i have problem i want to
select name_magazine from magazine
and i already import all library needed
and
Query q = EntityManger.createQuery ("SELECT name_magazine FROM Magazine");
List results = (List) q.getResultList ();
For(Sting s : result)
System.out.println(s);
but when i run this code it's error. can someone help...
java - AOP problem running Spring unit tests
I have a Spring web application which is configured to use JDK proxying for AOP. The AOP annotations (such as @Transactional) are declared on the interfaces, rather than the implementation classes.
The application itself works fine, but when I run the unit tests, it seems to be attempting to use CGLIB for the AOP functionality (instead of JDK proxying). This causes the tests to fail - I've appended the stack trace ...
Problem running Java .war on Tomcat
I am following the tutorial here:
http://nutch.sourceforge.net/docs/en/tutorial.html
Crawling works fine, as does the test search from the command line.
When I try to fire up tomcat after moving ROOT.war into place(and it unarchiving and creating a new ROOT folder during startup), I get a page with the 500...
java - Problem with number of rows in a dataset
My new problem is the following: an SQL query to a database (DB2) returns 1500 rows but BIRT shows me only 500 in the dataset-editor. To count them I used a computed column (Integer) with the following logic:
Total.count(row["VPK"])
I'm using the RCP-Designer (BIRT 2.1.3). How can i get the other rows as well?
java - Problem with threads
*I'm using Java.
I have this thread, agent, that explores a room to determine its size and clean it if it's dirty. Then I have the interface, which draws the agent as it explores the environment. Agent is subclassed from Thread, and Java takes care of managing the threads. All I do is create the thread and say object.start().
This works very well under normal circustances. However, the menus are enabled dur...
java - JSF JSTL problem with nested forEach
Inside a nested foreach, accessing the same variable is returning different values. This happens when the page is reloaded, not on first load.
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
(...)
xmlns:c="http://java.sun.com/jstl/core"
xmlns:h="http://java.sun.com/jsf/html">
(...)
<c:forEach items="#{controller.availableTransitions}" var="transition">
<c:forEach items=...
Java Swing Problem
I have a board with cards in which I have to find matches. I have two variables buttonA and buttonB to keep track of the squares clicked.
When they are equal I can remove them from the board by simply adding this code:
cards[buttonA].setVisible(false);
cards[buttonB].setVisible(false);
How can I place the same image on all the buttons after finding matches...
Java and MySQL date problem
I do a
rs.getTimestamp("datetime")
in Java.
In the database, this datetime is 2009/03/06 02:47:18
but the time is returned as 14:47:18
I'm not very knowledgeable about MySQL dates, so I would appreciate any explanation as to why this is happening.
Still can't find your answer? Check out these amazing Java communities for help...
Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)