I have a form with many data. In this form the user can click on "view report" button which will load a pdf file from the folder, if the report exists.
I'm trying to find a way that the button will appear flat and won't be able to click it if there is no report to load and the button will appear regular and will be abled to click on if the report exists and can be load.
basically i'm trying to avoid clicking on the button in any case and if the report exists it will be loaded and if not it will gives an error msg.
The goal is that just by looking at the button the user will know if there is a report or if there isn't.
How can I make it possible assuming I have 2 images ready (flat and regular).
if (fileExists)
JButton.setEnabled(true):
else
JButton.setEnabled(false);
Have you thought of just using:
myButton.setEnabled(false);
and later when it's ok to use the button:
myButton.setEnabled(true);
Related
We're using one of the new responsive themes of PrimeFaces 8 (Mirage if that matters) I've implemented a dynamic menu to create the menu of my page. Depending on several parameters, the landing page can be different. Example:
Suppose there's a communications environment in which the menu items are
Documents (opens by default)
E-mail
Pictures
When arriving in the communications environment, the application checks whether there are new e-mails. If so, the user won't arrive on the "Documents" page but on the "E-mails" page.
The theme uses cookies to restore the menu state based on what the user has chosen previously. So suppose last time (s)he has chosen "Pictures", the result now is that the menu item "Pictures" is marked as active-menuitem but the displayed page is "E-mail".
I was already able to clear the cookies so that no menu item is active, but now I'm trying to activate the correct menu item. I got most successful by calling
PF('sidebarMenu').activate($('.custom-active-menuitem').closest('li'));
PF('sidebarMenu').activate($('.custom-active-menuitem').closest('ul').closest('li'));
but since the page is rebuild using ajax, this only works once 🤨. Using the build-in .active-menuitem doesn't work so that's why I introduced .custom-active-menuitem that I set in Java code:
DefaultMenuItem.builder()
.value("E-mail")
.icon("fa fa-letter")
.command("#{communicationBean.openEmailPage()}")
.styleClass("custom-active-menuitem") // or something else to mark this item active
.process("#this")
.update(":page");
So now I'm puzzled. Can someone please get me in the correct direction? How can I make the theme show the menu item I choose as active one?
I work on a Java project with Echo Studio 3.
I have a servlet that display a Pdf file.
I call this servlet with a button that open a new window with this code:
Command open = new BrowserOpenWindowCommand("http://localhost:8080/MyApp/app/DisplayFile", "_blank");
Application.getActive().enqueueCommand(open);
I would like to allow the access to this servlet only to users who clicked on this button, but I don't know how to handle this.
Any idea?
Pass an additional parameter in the link to identify the click.
Or else capture the click event in javascript and add additional parameter to the server url to inform that the button has been pressed.
I have a serious problems with richtext field in my app. (Domino R901). I have extracted the scenario into simple Xpage with just one field and submit button only.
I have simple XPage now, with one field and submit button. RT field looks like this:
<xp:inputRichText id="inputRichText1" value="#{docui.body}"></xp:inputRichText>
Plus there is a standard button which runs JAVA action below with full submit:
This action is called on button click:
public void r(DominoDocument docui) throws NotesException {
Document cdoc = docui.getDocument(true);
if (cdoc.hasItem("body")){
print("Body exist");
} else {
print("Body doesnt exist");
}
docui.setDocument(cdoc);
}
Now when I enter some text into rich text field (CKEditor) and click on submit, it reloads the page (full submit) and I can see the text in CKEditor properly. Now when I do it 2nd time, text disapear and even in my JAVA code it says, that 'Body doesnt exist'. The problem seems to lie in fact, that CKEditor doesnt send content to server, when there is no change to it ... see here richtext control doesn't store the input content . I understand this behaviour for saved existing document, but when you have a new document, it simply doesnt submit value during second submit because it doesnt changed between requests. But because its a new unsaved document the value is simply discarded / lost . Is there any workaround how to deal with this?
This is a project on JSP.
1)I have this code where a button is pressed and the action is rendered to another page,which is a JSP page containing a pdf and the user is able to save it.
I had tried my code a month back and it worked fine,now when I try it,it doesnt work on chrome,works on mozilla though.
this is the line of code
response.setHeader("Content-Disposition", "inline; filename=Question.pdf");
2)My second problem is that,I have a reset button,this button resets the database.this function works fine on chrome but not on mozilla.I have no idea why it doesnt,there is no action taking place at all.
this is the line of code for that
<button type="button" onclick="reset.jsp">RESET</button>
For question 1):
What I know from the difference between "content-disposition", "attachment;filename=somefile.ext" and "content-disposition", "inline;filename=somefile.ext" is that in the inline case the browser will try to render it alone and if it can't it will prompt the user to download it. Maybe in your case you had an extension of Chrome that was capable of showing PDF files in the browser and now not. See Content-Disposition:What are the differences between "inline" and "attachment"?
As for question 2) :
This code onclick="reset.jsp" is not a valid construction. Onclick has to be a valid JavaScript function. See http://www.w3schools.com/jsref/event_onclick.asp. And it you case it not necessary to have it at all as you have an link inside the button which performs the actual action. I guess Chrome ignores this error and MOzilla not. Try removing onclick="reset.jsp" from the button.
I have jquery pop form to upload a file, after on submit (the page refresh and the pop close) i check something about the file and then if there's something wrong i need to pop up that form again (from the java code?), how could i do that ?
You should use ( or must be using) ajax in jquery with a popup.
When the user hits "submit", control goes to server side code.
The code runs to upload the file.
Whatever the result of upload (success/failure), that message is sent to the popup with ajax automatically.
In case, there is problem in uploading the file then, along with the failure message, you can send in the div which contains your form.
I think rather than refreshing the page to close the popup, allow the user to close the popup with close button.
When "something is wrong" the server-side code (this applies to any language) should include within the HTML content Javascript that will trigger the "form" to be displayed again.
As I feel dizzy presently,can't write the code,but will try to break whole procedure in multiple steps:-
On Trigger(by some event) a pop up form will open from submission,which will have a button which will be calling a OnClick Event,which will be containing an Ajax call for client server communication
till the response don't close or fade out the Pop up box.
from server expect two tags SUCCESS or ERROR
a) On SUCCESS, remove form DIV and fade out/close the pop up
with a success message b)On Error,display a refreshed form DIV
And so on