Using EL in <jsp:include> tag - el

i have a jsf 1.2 / rich faces 3.2.2 project (with java 6). i want to display menu bar conditionally depending on type of user logged in. From the question How to conditionally include a file in my template using JSF and Facelets? i tried the following:-
...
<td valign="top" align="left" height="100%">
</f:verbatim>
<jsp:include page="../Menu${authenticateBean.menuSuffix}.jsp" /> <f:verbatim></td>
...
i also tried
<jsp:include page="../Menu#{authenticateBean.menuSuffix}.jsp" />
...
where authenticateBean.menuSuffix is a string that will return "A" or "B" and ultimately, theoretically "MenuA.jsp" or "MenuB.jsp" page should include in my page. but i get following error
javax.servlet.ServletException: File "/pages/includes/LeftPan.jsp" not found
Help. Plz.

Heres how I managed it. Placing as an answer if ne one needs…
<%
AuthenticateBean authBean=
((AuthenticateBean)FacesUtils.getManagedBean(AuthenticateBean.MANAGED_NAME));
String panSuffix = authBean.getPanSuffix();
String impPage = "../includes/Menu"+ panSuffix +".jsp";
%>
.
.
.
<jsp:include page="<%= impPage %>" />
In the getPanSuffix() i have placed business logic that checks the type of user logged on and return a string accordingly. for Type "A" user. MenuA.jsp would display and for type "B" user MenuB.jsp would display. May be a primitive way of doing things but worked for me.
Thanks All.

Related

Initial letters missing while using type() in Cypress

Scenario:
<tr>
<td id="type1">
<div><span></span></div>
</td>
<td id="type2">
<div><span></span></div>
</td>
</tr>
cy.get('#type1').type('Abcd') // skips the initial letters ie,
// it actually types 'bcd' or 'cd'
There's an issue here Missing letters when using type #3817. I can see this issue is resolved, but I'm still facing this issue. Any workarounds?
This question leaves out some vital bits that I would like to clear up.
If you try out the click-trick on that HTML snippet, you will come a cropper.
This is the error
cy.type() failed because it requires a valid typeable element.
A typeable element matches one of the following selectors:
a[href]
area[href]
input
select
textarea
button
iframe
[tabindex]
[contenteditable]
The last two are the only options for this particular HMTL, so you could make it work like this:
cy.get('#type1')
.invoke('attr', 'contenteditable') // make it editable
.type('Abcd')
.should('contain', 'Abcd') // confirm it has the text
.invoke('removeAttr', 'contenteditable') // optionally remove the attribute
.should('not.have.attr', 'contenteditable')

Update certain data in SQL with JSP

i've been learning web programming (JSP and SQL) for the past few days, i need help with certain problem, so i need to show the list of all name of members from my database, add button beside it, and when i click it, i need to update the data in database, which name is exactly the same name besides the button .
I have successfully show the data and button, and i know syntax for updating in SQL, but i have no idea how to validate when i click the button, it updates the data with the same name exactly besides the button. Let's just pretend all name is unique. This is my sample code:
<div id="textArea">
<%
String query = "SELECT * FROM member";
ResultSet rs = st.executeQuery(query);
while(rs.next()){%>
<table>
<tr>
<td><%out.print(rs.getString("Fullname"));%></td>
<td> <input type="button" value="Change Role"/> </td>
</tr>
</table>
<%
}
%>
</div>
Any help is really appreciated. thanks!
You have to write Java code in a JSP Page for updating certain data from JSP.
You can write Java Code inside a scriptlet in a JSP page.
You have to write scriptlet inside <% ...%> tag, Please see sample below:
<%
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test");
Statement st=con.createStatement();
......
%>
Please follow the post below to execute update query directly from JSP:
Jsp sql update query

How to set the default value of input item with jQuery EasyUI framework

I am trying to set the default value of an input item from last two days.
For this, i have also searched in google but till not cannot find the solution.
I am using jQuery EasyUI framework.
<div class="fitem">
<tr>
<td></td>
<td>
<input type="text" class="easyui-validatebox" name="insertby" id="insertby" size="20">
</td>
</tr>
</div>
<script>
var s = '<?php echo $logname; ?>';
document.getElementById('insertby').value = s ;
alert(s);
</script>
As I am unable to add a comment to ask you to try stuff, I will try my best to help you out!
Firstly, your code works for me. However, there are times where other javascript codes causes errors and stops the code execution before your block of code. You might want to try pressing F12 on your Chrome browser to see if you encounter any errors before your block of code to ensure that all is well.
this code snip might have you
http://www.jeasyui.com/forum/index.php?topic=2623.0
$('#insertby').validatebox('setValue', s);
I took me while to "get it" too.
Actually, jquery easyUI modifies the DOM on the fly to make its fancy things in a way that the original input box is "gone" while you obtain their fancy widget instead. That's why modifying the input field directly has no effect, it is hidden actually. I guess this is done so because their getters/setters should be used in order to update everything correctly.
EasyUI is very easy to set up and play with, but it's way to operate on elements is rather unintuitive. But once you got the hang of it, it should be all right.
Use
setValue. $('idofcombogrid').('setValue',id_value);
The id_value refers to the value of idField as defined initially for the combogrid.

SSI tag inside html form?

I have a simple HTML form in which I would like to pre-populate the fields with SSI tag data. This is what I have done:
<form method="get" action="flashWrite.cgi">
<li><i>Network Configuration</i>
<br>
<table border="0">
<tr>
<td>IP Address:</td><td><input value="<!--#ipaddr-->" name="ipaddr"></td>
</tr>
<tr>
<td>Subnet Mask:</td><td><input value="<!--#snetmsk-->" name="snetmsk"></td>
</tr>
<tr>
<td>Gateway:</td><td><input value="<!--#gateway-->" name="gateway"> </td>
</tr></table>
The results are somewhat disapointing:
Never-mind that these IP values are showing up as 32 bit integers, I'll deal with that later. What bothers me is that the tags are showing up in the form. Can someone tell me why in the form, the value is appended to the tag instead of replacing the tag?
This is taking place on a TI LM3S9D96 MCU running an LWIP stack.
If html form code is in firmware, you will create the form as you want.
For example,
In Html:
<td>IP Address:</td><td><!--#form_ipaddr--></td>
In Firmware, code for form_ipaddr tag :
sprintf(pcBuffer, "<input value="%s" name="ipaddr">", pcIpAddrString);
You need to define LWIP_HTTPD_SSI_INCLUDE_TAG 0.
By default the tags are included, helps in debugging.
HTML comment cannot (should not) be placed in another tag as it is a tag itself. And that's it.
But, in this case, it depends on how are you replacing those tags.
in httpd_opts.h :
/** Set this to 0 to not send the SSI tag (default is on, so the tag will
* be sent in the HTML page */
#if !defined LWIP_HTTPD_SSI_INCLUDE_TAG
#define LWIP_HTTPD_SSI_INCLUDE_TAG 0
#endif
set LWIP_HTTPD_SSI_INCLUDE_TAG to 0
In that case the tag will not be sent, but its value will.

<html:link> tag

I am new to struts tag libraries. I want to generate an anchor to define a hyperlink destination inside the same document. My code is like this:
<html:link anchor="abc" >
This is to test anchors
</html:link>
...Some other tags here
<html:link linkName = "abc" >
Anchor
</html:link>
The error I am getting is Cannot create rewrite URL: java.net.MalformedURLException: You must specify exactly one of "forward", "href", or "page"
Can anybody tell me how to solve this?
Thanks
as i understand struts and from apache
You must specify exactly one of the action attribute, the forward attribute, the href attribute, the linkName attribute, or the page attribute.
so in your first tag, i would guess that you would need to add an href tag and the anchor is added on to that. then your tag with linkname should work
that is
<html:link href="someurl" anchor="abc" >
This is to test anchors
</html:link>
This worked for me.
Below is the scenario, in which i got the error.
<appl:resource defaultValue="Appl Error" op="GET" category="shunmugaActionMapping" name="specification" property="shunmugaType" id="shunmugaStartMapping" type="string" >
<td class="<xd:valueOf name="rowStyle"/>">
<div class="listRowLink"><html:link page="<%=shunmugaStartMapping%>" paramName="specification" paramProperty="routerId" paramId="detailRouterId">> Details</html:link>
</div>
</td>
This was throwing the following error:
servlet E com.ibm.ws.webcontainer.servlet.ServletWrapper service SRVE0068E:
Uncaught exception created in one of the service methods of the servlet
/jsp/List.jsp in application Sundaram. Exception created :
com.ibm.websphere.servlet.error.ServletErrorReport:
javax.servlet.jsp.JspException: Cannot create rewrite URL:
java.net.MalformedURLException: You must specify exactly one of
"forward", "href", "page" or "action"
at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:695)
All i did is i added the closure at the end:
</appl:resource>
The problem got solved and I am fine now.
Thanks,
Shunmuga